BPF를 사용한 SSH 향상된 세션 녹화
이 가이드는 BPF를 사용한 SSH 향상된 세션 녹화와 Teleport 클러스터에서 설정하는 방법을 설명합니다. Teleport의 기본 SSH 및 Kubernetes 세션 녹화 기능은 터미널에 출력되는 내용을 캡처합니다.
이 가이드는 BPF를 사용한 SSH 향상된 세션 녹화와 Teleport 클러스터에서 설정하는 방법을 설명합니다.
Teleport의 기본 SSH 및 Kubernetes 세션 녹화 기능은 터미널에 출력되는 내용을 캡처합니다.
이에는 본질적인 장점이 있습니다. 예를 들어, 입력이 캡처되지 않으므로 Teleport 세션 녹화에는 일반적으로 터미널에 입력된 비밀번호가 포함되지 않습니다.
단점은 세션 녹화를 덜 유용하게 만드는 몇 가지 기술이 있다는 것입니다:
- 난독화. 예를 들어,
echo Y3VybCBodHRwOi8vd3d3LmV4YW1wbGUuY29tCg== | base64 --decode | sh명령은curl http://www.example.com을 포함하지 않지만, 디코딩하면 그것이 실행됩니다. - 셸 스크립트. 예를 들어, 사용자가 스크립트를 업로드하고 실행하면 스크립트 내에서 실행된 명령은 캡처되지 않고 출력만 캡처됩니다.
- 터미널 제어. 터미널은 터미널 에코를 비활성화하는 기능을 포함한 다양한 제어를 지원합니다. 이는 자격 증명을 요청할 때 자주 사용됩니다. 터미널 에코를 비활성화하면 명령이 캡처되지 않고 실행될 수 있습니다.
또한 구조화되지 않은 특성으로 인해 세션 녹화는 모니터링 및 알림에 수집하고 활용하기 어렵습니다.
Teleport 향상된 세션 녹화는 고급 보안과 더 큰 로깅 기능을 제공하고 사용자와 그 활동을 더 잘 연관시켜 세 가지 우려 사항을 모두 해소합니다.
Teleport 향상된 세션 녹화는 자체적으로 안전한 환경을 제공하지 않으며 Linux 보안 모듈(SELinux, AppArmor 등)의 대체품이 아닙니다. 핵심 시스템 바이너리 및 라이브러리에 대한 적절한 접근 제어와 잘 설계된 사용자 관리를 포함하여 신뢰할 수 있는 호스트 환경을 강제하는 합리적인 시스템 강화 방법과 함께 사용해야 합니다.
권한 있는 사용자(root 또는 sudo 통해)는 세션 녹화 활동에 간섭할 수 있습니다(필요한 라이브러리 언로딩/비활성화, Teleport 실행 방식 변경, 커널 기능 조작, 터널 생성 또는 제한된 세션 외부에서 작업 수행 등). 또한 모니터링되는 세션과 모니터링되지 않는 콘솔 세션 또는 ptrace 권한이 모두 있는 로컬 사용자는 녹화에 완전히 캡처되지 않을 수 있습니다.
데몬(systemd, crond, atd 등)을 통해 실행된 명령은 녹화된 세션 범위 밖에 있을 수 있습니다. 무단 데이터 전송을 방지하기 위해 이그레스 트래픽에 대한 적절한 네트워크 기반 제한도 구현해야 합니다.
또한 전체 바이너리 경로(잠재적인 심볼릭 링크 고려), 공유 라이브러리 사전 로딩을 통한 수정 사항, 환경 변수와 같은 특정 포렌식 정보는 세션 녹화에 캡처되지 않을 수 있습니다.
사전 요구사항#
-
A running Teleport cluster. If you want to get started with Teleport, sign up for a free trial or set up a demo environment.
-
The
tctlandtshclients.Installing `tctl` and `tsh` clients
-
Determine the version of your Teleport cluster. The
tctlandtshclients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at/v1/webapi/findand use a JSON query tool to obtain your cluster version. Replace with the web address of your Teleport Proxy Service:$ TELEPORT_DOMAIN= $ TELEPORT_VERSION="$(curl -s https://$TELEPORT_DOMAIN/v1/webapi/find | jq -r '.server_version')" -
Follow the instructions for your platform to install
tctlandtshclients:
-
-
Teleport 노드 서비스를 실행하는 데 사용할 호스트 하나 이상. 호스트는 Linux 커널 5.8 이상을 실행해야 합니다.
uname명령으로 커널 버전을 확인할 수 있습니다. 출력은 다음과 유사해야 합니다.$ uname -r # 5.8.17Linux 커널 및 배포판의 필수 버전에 대한 자세한 내용은 아래를 참조하세요.
표준 세션 녹화는 이전 Linux 커널에서도 작동합니다. 자세한 내용은 Teleport 세션 녹화를 참조하세요.
Linux 배포판 및 지원 커널#
Teleport는 amd64 및 arm64 아키텍처에서 BPF를 사용한 향상된 세션 녹화를 지원합니다.
| 배포판 이름 | 배포판 버전 | 커널 버전 |
|---|---|---|
| Ubuntu "Groovy Gorilla" | 20.10 | 5.8+ |
| Fedora | 33 | 5.8+ |
| Arch Linux | 2020.09.01 | 5.8.5+ |
| Flatcar | 2765.2.2 | 5.10.25+ |
| Amazon Linux | 2 and 2023 | 5.10+ |
To check that you can connect to your Teleport cluster, sign in with tsh login, then
verify that you can run tctl commands using your current credentials.
For example, run the following command, assigning to the domain name of the Teleport Proxy Service in your cluster and to your Teleport username:
$ tsh login --proxy= --user=
$ tctl status
# Cluster (=teleport.url=)
# Version (=teleport.version=)
# CA pin (=presets.ca_pin=)
If you can connect to the cluster and run the tctl status command, you can use your
current credentials to run subsequent tctl commands from your workstation.
If you host your own Teleport cluster, you can also run tctl commands on the computer that
hosts the Teleport Auth Service for full permissions.
1단계/2단계. Teleport 노드 구성#
노드에 Teleport 설치#
Teleport 노드를 실행할 호스트에서 환경에 맞는 지침에 따라 Teleport를 설치합니다.
To install a Teleport Agent on your Linux server:
The recommended installation method is the cluster install script. It will select the correct version, edition, and installation mode for your cluster.
-
Assign to your Teleport cluster hostname and port, but not the scheme (https://).
-
Run your cluster's install script:
$ curl "https:///scripts/install.sh" | sudo bash
토큰 생성#
tctl 도구를 사용하여 노드가 클러스터에 참여하는 데 사용할 초대 토큰을 생성합니다. 다음 예시에서 새 토큰은 5분의 TTL로 생성됩니다:
# Generate a short-lived invitation token for a new node:
$ tctl nodes add --ttl=5m --roles=node
# The invite token: (=presets.tokens.first=)
# You can also list all generated non-expired tokens:
$ tctl tokens ls
# Token Type Expiry Time
# ------------------------ ----------- ---------------
# (=presets.tokens.first=) Node 25 Sep 18 00:21 UTC
# ... or revoke an invitation token before it's used:
$ tctl tokens rm (=presets.tokens.first=)
구성 파일 생성#
다음 내용으로 /etc/teleport.yaml에 Teleport 노드를 설정합니다.
# Example config to be saved as etc/teleport.yaml
version: v3
teleport:
nodename: graviton-node
# The token you created earlier
auth_token: (=presets.tokens.first=)
# Replace with the address of the Teleport Auth Service
auth_server: 127.0.0.1:3025
# Or specify the Proxy Service address.
proxy_server: 127.0.0.1:3080
data_dir: /var/lib/teleport
proxy_service:
enabled: false
auth_service:
enabled: false
ssh_service:
enabled: true
enhanced_recording:
# Enable or disable enhanced auditing for this node. Default value: false.
enabled: true
# Optional: command_buffer_size is optional with a default value of 8 pages.
command_buffer_size: 8
# Optional: disk_buffer_size is optional with default value of 128 pages.
disk_buffer_size: 128
# Optional: network_buffer_size is optional with default value of 8 pages.
network_buffer_size: 8
# Optional: Controls where cgroupv2 hierarchy is mounted. Default value:
# /cgroup2.
cgroup_path: /cgroup2
# Optional: Controls the path inside cgroupv2 hierarchy where Teleport
# cgroups will be placed. Default value: /teleport
root_path: /teleport
세션 시스템 리소스 격리
동일한 시스템에서 여러 Teleport 인스턴스를 운영하는 경우, root_path 구성을 사용자 정의하여 세션 시스템 리소스의 기본 cgroupv2 슬라이스 경로를 변경합니다. 이렇게 하면 서로 다른 Teleport 인스턴스의 세션 간 보안 격리가 보장되어 별도의 보안 규칙과 리소스 제어를 적용할 수 있습니다.
노드에서 Teleport 시작#
Configure the Teleport SSH Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Teleport SSH Service.
You can check the status of the Teleport SSH Service with systemctl status teleport
and view its logs with journalctl -fu teleport.
2단계/2단계. 감사 로그 검사#
향상된 세션 녹화 이벤트는 Teleport의 감사 로그에 표시되며, Teleport Web UI를 방문하여 검사할 수 있습니다.
실행된 각 명령은 다음과 유사한 session.command 이벤트를 생성합니다:
{
"argv": [
"https://wttr.in"
],
"cgroup_id": 2360,
"cluster_name": "purple",
"code": "T4000I",
"ei": 50,
"event": "session.command",
"login": "ec2-user",
"namespace": "default",
"path": "/bin/curl",
"pid": 5007,
"ppid": 4985,
"program": "curl",
"return_code": 0,
"server_hostname": "ip-172-31-34-128.us-east-2.compute.internal",
"server_id": "531dc1de-c2c9-49bd-a0e3-4f4f3a523f5f",
"sid": "86aca627-971d-4883-854d-d309ba04c658",
"time": "2023-07-04T16:42:20.54Z",
"uid": "9b825e22-744d-4130-94c5-dea49198ae3d",
"user": "alice@goteleport.com"
}
네트워크 연결은 다음과 유사한 session.network 이벤트로 기록됩니다:
{
"action": 0,
"cgroup_id": 2360,
"cluster_name": "purple",
"code": "T4002I",
"dst_addr": "5.9.243.187",
"dst_port": 443,
"ei": 51,
"event": "session.network",
"login": "ec2-user",
"namespace": "default",
"operation": 0,
"pid": 5007,
"program": "curl",
"server_hostname": "ip-172-31-34-128.us-east-2.compute.internal",
"server_id": "531dc1de-c2c9-49bd-a0e3-4f4f3a523f5f",
"sid": "86aca627-971d-4883-854d-d309ba04c658",
"src_addr": "172.31.34.128",
"time": "2023-07-04T16:42:20.55Z",
"uid": "da151350-bf45-4a04-a62b-7a4fc805e744",
"user": "alice@goteleport.com",
"version": 4
}
향상된 세션 녹화가 활성화되면 세션 종료 시 발행되는 session.end 이벤트에도 다음과 유사하게 "enhanced_recording": true 필드가 포함됩니다:
{
"code": "T2004I",
"ei": 23,
"enhanced_recording": true,
"event": "session.end",
"interactive": true,
"namespace": "default",
"participants": [
"alice@goteleport.com"
],
"server_id": "585fc225-5cf9-4e9f-8ff6-1b0fd6885b09",
"sid": "ca82b98d-1d30-11ea-8244-cafde5327a6c",
"time": "2019-12-12T22:44:46.218Z",
"uid": "83e67464-a93a-4c7c-8ce6-5a3d8802c3b2",
"user": "alice@goteleport.com"
}
Teleport 클러스터가 파일 기반 이벤트 로그를 사용하는 경우, Teleport Auth Service 호스트에서 감사 로그를 검사할 수 있습니다.
클러스터가 파일 기반 이벤트 로그를 사용하고 있나요?
Teleport의 세션 녹화 백엔드는 teleport.storage.audit_sessions_uri 필드를 통해 구성됩니다. 제공된 URI에 클라우드 기반 서비스에 속하는 스키마(예: s3:// 또는 dynamodb://)가 포함된 경우, Auth Service 호스트의 파일 시스템에서 세션 녹화를 검사할 수 없습니다.
아래와 같이 /var/lib/teleport/log의 내용을 검사합니다:
$ teleport-auth ~: tree /var/lib/teleport/log
# /var/lib/teleport/log
# ├── 1048a649-8f3f-4431-9529-0c53339b65a5
# │ ├── 2020-01-13.00:00:00.log
# │ └── sessions
# │ └── default
# │ ├── fad07202-35bb-11ea-83aa-125400432324-0.chunks.gz
# │ ├── fad07202-35bb-11ea-83aa-125400432324-0.events.gz
# │ ├── fad07202-35bb-11ea-83aa-125400432324-0.session.command-events.gz
# │ ├── fad07202-35bb-11ea-83aa-125400432324-0.session.network-events.gz
# │ └── fad07202-35bb-11ea-83aa-125400432324.index
# ├── events.log -> /var/lib/teleport/log/1048a649-8f3f-4431-9529-0c53339b65a5/2020-01-13.00:00:00.log
# ├── playbacks
# │ └── sessions
# │ └── default
# └── upload
# └── sessions
# └── default
감사 로그 상태를 빠르게 확인하려면 tail -f /var/lib/teleport/log/events.log로 로그를 조회하면 됩니다. Teleport에서 캡처한 결과는 각 명령 및 네트워크 요청에 대한 JSON 로그가 됩니다.
향상된 세션 녹화 이벤트는 Teleport의 감사 로그에 표시되며, Teleport Web UI를 방문하여 검사할 수 있습니다.
실행된 각 명령은 다음과 유사한 session.command 이벤트를 생성합니다:
{
"argv": [
"https://wttr.in"
],
"cgroup_id": 2360,
"cluster_name": "purple",
"code": "T4000I",
"ei": 50,
"event": "session.command",
"login": "ec2-user",
"namespace": "default",
"path": "/bin/curl",
"pid": 5007,
"ppid": 4985,
"program": "curl",
"return_code": 0,
"server_hostname": "ip-172-31-34-128.us-east-2.compute.internal",
"server_id": "531dc1de-c2c9-49bd-a0e3-4f4f3a523f5f",
"sid": "86aca627-971d-4883-854d-d309ba04c658",
"time": "2023-07-04T16:42:20.54Z",
"uid": "9b825e22-744d-4130-94c5-dea49198ae3d",
"user": "alice@goteleport.com"
}
네트워크 연결은 다음과 유사한 session.network 이벤트로 기록됩니다:
{
"action": 0,
"cgroup_id": 2360,
"cluster_name": "purple",
"code": "T4002I",
"dst_addr": "5.9.243.187",
"dst_port": 443,
"ei": 51,
"event": "session.network",
"login": "ec2-user",
"namespace": "default",
"operation": 0,
"pid": 5007,
"program": "curl",
"server_hostname": "ip-172-31-34-128.us-east-2.compute.internal",
"server_id": "531dc1de-c2c9-49bd-a0e3-4f4f3a523f5f",
"sid": "86aca627-971d-4883-854d-d309ba04c658",
"src_addr": "172.31.34.128",
"time": "2023-07-04T16:42:20.55Z",
"uid": "da151350-bf45-4a04-a62b-7a4fc805e744",
"user": "alice@goteleport.com",
"version": 4
}
향상된 세션 녹화가 활성화되면 세션 종료 시 발행되는 session.end 이벤트에도 다음과 유사하게 "enhanced_recording": true 필드가 포함됩니다:
{
"code": "T2004I",
"ei": 23,
"enhanced_recording": true,
"event": "session.end",
"interactive": true,
"namespace": "default",
"participants": [
"alice@goteleport.com"
],
"server_id": "585fc225-5cf9-4e9f-8ff6-1b0fd6885b09",
"sid": "ca82b98d-1d30-11ea-8244-cafde5327a6c",
"time": "2019-12-12T22:44:46.218Z",
"uid": "83e67464-a93a-4c7c-8ce6-5a3d8802c3b2",
"user": "alice@goteleport.com"
}
[선택 사항] 이벤트 필터링#
특정 사용자에 대해 향상된 세션 녹화가 감사하는 이벤트를 필터링할 수 있습니다.
spec.options.enhanced_recording 필드를 다음과 같이 편집합니다:
version: v8
kind: role
metadata:
name: enhanced-recording
spec:
options:
enhanced_recording:
- command
- disk
- network
이 예시는 Teleport SSH Service가 명령, 디스크 및 네트워크 활동과 관련된 이벤트를 캡처하도록 활성화합니다. 사용자의 역할 중 하나 이상에 특정 옵션이 포함되어 있으면 Teleport SSH Service가 해당 사용자에 대해 지정된 종류의 감사 이벤트를 캡처합니다.
역할에서 enhanced_recording 필드가 비어 있으면 해당 역할의 기본값은 다음과 같습니다:
- command
- network
