인포레터에서 최신 DevOps 트렌드를 격주로 만나보세요!
Teleport 감사 이벤트를 Panther에 내보내기
Panther는 클라우드 네이티브 보안 분석 플랫폼입니다. 이 가이드에서는 Fluentd를 사용하여 Teleport 감사 이벤트를 Panther로 전달하는 방법을 설명합니다.
작동 방식
Teleport 이벤트 핸들러는 mTLS를 사용하여 Fluentd와 통신하도록 설계되어 안전한 채널을 설정합니다. 이 설정에서 이벤트 핸들러는 이벤트를 Fluentd로 전송하고, Fluentd는 이를 S3로 전달하여 Panther가 수집할 수 있도록 합니다.
전제 조건
-
실행 중인 Teleport 클러스터 버전 17.0.0-dev 이상. Teleport를 시작하려면 가입하여 무료 평가판을 이용하거나 데모 환경 설정 방법을 확인하십시오.
-
tctl
관리자 도구와tsh
클라이언트 도구.tctl
및tsh
다운로드 방법에 대한 지침은 설치를 방문하십시오.
권장: 플러그인에 단기간 사용 가능한 Teleport 자격 증명을 제공하기 위해 Machine ID를 구성합니다. 이 가이드를 따르기 전에 Machine ID 배포 가이드를 따라 tbot
바이너리를 인프라에서 실행하세요.
- Panther 계정.
- 이벤트 핸들러를 실행할 서버, 가상 머신, Kubernetes 클러스터 또는 Docker 환경. 아래의 지침은 테스트를 위한 로컬 Docker 컨테이너를 가정합니다.
- Fluentd 버전 v1.12.4 이상. Teleport 이벤트 핸들러는 기존 Fluentd 시스템에 통합하거나 새 설정에 사용할 수 있는 새
fluent.conf
파일을 만듭니다. - 로그를 저장할 S3 버킷. Panther는 이 버킷에서 로그를 수집합니다.
아래의 지침은 VM에서 이벤트 핸들러 플러그인을 로컬로 테스트하는 방법을 보여줍니다. 다른 환경에 맞게 경로, 포트 및 도메인을 조정해야 합니다.
- 연결이 가능한지 확인하기 위해
tsh login
으로 로그인한 다음, 현재 자격 증명을 사용하여tctl
명령어를 실행할 수 있는지 확인하십시오. 예를 들어:클러스터에 연결할 수 있고tsh login --proxy=teleport.example.com --user=email@example.comtctl status클러스터 teleport.example.com
버전 17.0.0-dev
CA 핀 sha256:abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678abdc1245efgh5678
tctl status
명령어를 실행할 수 있다면, 현재 자격 증명을 사용하여 워크스테이션에서 후속tctl
명령어를 실행할 수 있습니다.
자신의 Teleport 클러스터를 호스팅하는 경우, Teleport Auth Service를 호스팅하는 컴퓨터에서 전체 권한으로tctl
명령어를 실행할 수도 있습니다.
1/7 단계. 이벤트 핸들러 플러그인 설치
Teleport 이벤트 핸들러는 Fluentd 전달자와 함께 실행되며, Teleport의 이벤트 API에서 이벤트를 수신하고 이를 Fluentd로 전달합니다.
Event Handler 플러그인은 다운로드를 위해 amd64
및 arm64
바이너리로 제공됩니다.
필요한 버전으로 ARCH
를 교체하세요.
curl -L -O https://cdn.teleport.dev/teleport-event-handler-v17.0.0-dev-linux-ARCH-bin.tar.gztar -zxvf teleport-event-handler-v17.0.0-dev-linux-ARCH-bin.tar.gzsudo ./teleport-event-handler/install
Event Handler 플러그인은 다운로드를 위해 amd64
및 arm64
바이너리로 제공됩니다.
필요한 버전으로 ARCH
를 교체하세요.
curl -L -O https://cdn.teleport.dev/teleport-event-handler-v17.0.0-dev-darwin-ARCH-bin.tar.gztar -zxvf teleport-event-handler-v17.0.0-dev-darwin-ARCH-bin.tar.gzsudo ./teleport-event-handler/install
Docker가 설치되고 실행 중인지 확인하세요.
docker pull public.ecr.aws/gravitational/teleport-plugin-event-handler:17.0.0-dev
Helm이 Teleport Helm 리포지토리에 호스팅된 차트를 설치할 수 있도록 하려면 helm repo add
를 사용하세요:
helm repo add teleport https://charts.releases.teleport.dev
원격 리포지토리의 차트 캐시를 업데이트하려면 helm repo update
를 실행하세요:
helm repo update
Go >= 1.22가 설치되어 있어야 합니다.
Universal Forwarder 호스트에서 다음 명령어를 실행하세요:
git clone https://github.com/gravitational/teleport.git --depth 1 -b branch/v17cd teleport/integrations/event-handlermake build
결과적으로 생성된 실행 파일의 이름은 event-handler
입니다. 이 가이드를 계속 따르려면 이 파일의 이름을 teleport-event-handler
로 변경하고 /usr/local/bin
으로 이동하세요.
2/7 단계. 플러그인 구성 생성
configure
명령을 실행하여 샘플 구성을 생성합니다.
mytenant.teleport.sh
를 Teleport Enterprise Cloud 테넌트의 DNS 이름으로 바꿉니다:
teleport-event-handler configure . mytenant.teleport.sh:443
configure
명령을 실행하여 샘플 구성을 생성합니다.
teleport.example.com:443
을 Teleport의 Proxy Service의 DNS 이름과 HTTPS 포트로 바꿉니다:
teleport-event-handler configure . teleport.example.com:443
configure
명령을 실행하여 샘플 구성을 생성합니다.
TELEPORT_CLUSTER_ADDRESS
를 Teleport Auth Service 또는 Proxy Service의 DNS 이름과 포트에 할당합니다:
TELEPORT_CLUSTER_ADDRESS=mytenant.teleport.sh:443docker run -v `pwd` :/opt/teleport-plugin -w /opt/teleport-plugin public.ecr.aws/gravitational/teleport-plugin-event-handler:17.0.0-dev configure . ${TELEPORT_CLUSTER_ADDRESS?}
감사 이벤트를 내보내려면 루트 인증서와 클라이언트 자격 증명이 비밀로 사용 가능해야 합니다.
다음 명령을 사용하여 Kubernetes에서 그 비밀을 생성합니다:
kubectl create secret generic teleport-event-handler-client-tls --from-file=ca.crt=ca.crt,client.crt=client.crt,client.key=client.key
이 명령은 ca.crt
, client.crt
, 및 client.key
의 내용을 비밀로 패킹하여 헬름 차트가 적절한 경로에 마운트할 수 있도록 합니다.
configure
명령을 실행하여 샘플 구성을 생성합니다:
docker run -v `pwd` :/opt/teleport-plugin -w /opt/teleport-plugin public.ecr.aws/gravitational/teleport-plugin-event-handler:17.0.0-dev configure .
다음과 같은 출력을 볼 수 있습니다:
Teleport event handler 17.0.0-dev
[1] mTLS Fluentd 인증서가 생성되어 ca.crt, ca.key, server.crt, server.key, client.crt, client.key에 저장되었습니다.
[2] 샘플 teleport-event-handler 역할 및 사용자 파일 teleport-event-handler-role.yaml이 생성되었습니다.
[3] 샘플 fluentd 구성 파일 fluent.conf가 생성되었습니다.
[4] 플러그인 구성 파일 teleport-event-handler.toml이 생성되었습니다.
플러그인은 여러 설정 파일을 생성합니다:
ls -l-rw------- 1 bob bob 1038 Jul 1 11:14 ca.crt
-rw------- 1 bob bob 1679 Jul 1 11:14 ca.key
-rw------- 1 bob bob 1042 Jul 1 11:14 client.crt
-rw------- 1 bob bob 1679 Jul 1 11:14 client.key
-rw------- 1 bob bob 541 Jul 1 11:14 fluent.conf
-rw------- 1 bob bob 1078 Jul 1 11:14 server.crt
-rw------- 1 bob bob 1766 Jul 1 11:14 server.key
-rw------- 1 bob bob 260 Jul 1 11:14 teleport-event-handler-role.yaml
-rw------- 1 bob bob 343 Jul 1 11:14 teleport-event-handler.toml
파일들 | 목적 |
---|---|
ca.crt 및 ca.key | Fluentd용 자체 서명된 CA 인증서 및 개인 키 |
server.crt 및 server.key | Fluentd 서버 인증서 및 키 |
client.crt 및 client.key | 생성된 CA로 서명된 Fluentd 클라이언트 인증서 및 키 |
teleport-event-handler-role.yaml | Teleport의 이벤트 핸들러를 위한 user 및 role 리소스 정의 |
fluent.conf | Fluentd 플러그인 구성 |
이 가이드는 이벤트 핸들러가 로그 포워더와 동일한 호스트 또는 Kubernetes 파드에서 실행되고 있다고 가정합니다.
그렇지 않은 경우, 이벤트 핸들러에 localhost
이외의 주체에 대한 mTLS 인증서를 생성하도록 지시해야 합니다.
이를 위해 teleport-event-handler
의 configure 명령어의 --cn
및 --dns-names
플래그를 사용하십시오.
예를 들어 로그 포워더의 주소가 forwarder.example.com
이고 이벤트 핸들러의 주소가 handler.example.com
인 경우, 다음 configure
명령을 실행합니다:
teleport-event-handler configure --cn=handler.example.com --dns-names=forwarder.example.com
이 명령은 --cn
의 값으로 설정된 주체를 가진 클라이언트 및 서버 인증서를 생성합니다.
--dns-names
플래그는 DNS 이름의 쉼표로 구분된 목록을 허용합니다.
이 플래그는 목록의 각 DNS 이름에 대해 서버 인증서(로그 포워더에 제공할 인증서)에 주체 대안 이름(SAN)을 추가합니다.
이벤트 핸들러는 각 DNS 이름을 조회한 후 SAN으로 추가하며, 조회에 실패할 경우 오류와 함께 종료됩니다.
3/7 단계. 감사 이벤트를 읽기 위한 사용자 및 역할 생성
teleport-event-handler configure
명령은 teleport-event-handler-role.yaml
이라는 파일을 생성했습니다. 이 파일은 event
API에 대한 읽기 전용 액세스를 가진 teleport-event-handler
역할과 사용자를 정의합니다:
kind: role
metadata:
name: teleport-event-handler
spec:
allow:
rules:
- resources: ["event", "session"]
verbs: ["list", "read"]
version: v5
---
kind: user
metadata:
name: teleport-event-handler
spec:
roles: ["teleport-event-handler"]
version: v2
이 파일을 작업 스테이션으로 이동하거나 위의 코드 조각을 붙여넣어 재생성한 후, 작업 스테이션에서 tctl
을 사용하여 역할과 사용자를 생성하십시오:
tctl create -f teleport-event-handler-role.yamluser "teleport-event-handler" has been created
role 'teleport-event-handler' has been created
4/7 단계. teleport-event-handler 자격 증명 생성
이벤트 핸들러 역할에 대한 자격 증명 발급 활성화
역할이 생성되었으므로, 이제 Machine ID 봇이 이 역할에 대한 자격 증명을 생성할 수 있도록 허용해야 합니다.
이는 tctl
을 사용하여 수행할 수 있으며, my-bot
을 여러분의 봇 이름으로 교체하면 됩니다:
tctl bots update my-bot --add-roles teleport-event-handler
Teleport 클러스터에서 이벤트 핸들러 플러그인이 이벤트를 전달하려면 클러스터의 인증 기관에서 서명된 자격 증명이 필요합니다. teleport-event-handler
사용자는 자체적으로 이를 요청할 수 없으며, 다른 사용자가 이 계정을 임퍼소네이트(impersonate) 하여 자격 증명을 요청해야 합니다.
teleport-event-handler
사용자를 임퍼소네이트할 수 있는 역할을 만듭니다. 먼저, 아래 YAML 문서를 teleport-event-handler-impersonator.yaml
파일에 붙여넣습니다:
kind: role
version: v5
metadata:
name: teleport-event-handler-impersonator
spec:
options:
# max_session_ttl은 이 역할을 가진 사용자가 발급받는 SSH 인증서의 TTL(유효 기간)을 정의합니다.
max_session_ttl: 10h
# 이 섹션은 이 역할을 가진 사용자가 허용되는 리소스/행위 조합의 목록을 선언합니다. 기본적으로 아무것도 허용되지 않습니다.
allow:
impersonate:
users: ["teleport-event-handler"]
roles: ["teleport-event-handler"]
다음으로, 역할을 생성합니다:
tctl create teleport-event-handler-impersonator.yaml
이 역할을 이벤트 핸들러용 서명된 자격 증명을 생성하는 사용자에게 추가합니다:
teleport-event-handler-impersonator
역할을 Teleport 사용자에게 할당하려면, 인증 제공자에 맞는 적절한 명령어를 실행하십시오:
-
로컬 사용자의 역할을 쉼표로 구분된 목록으로 가져옵니다:
ROLES=$(tsh status -f json | jq -r '.active.roles | join(",")') -
새로운 역할을 추가하기 위해 로컬 사용자를 수정합니다:
tctl users update $(tsh status -f json | jq -r '.active.username') \ --set-roles "${ROLES?},teleport-event-handler-impersonator" -
Teleport 클러스터에서 로그아웃한 후 다시 로그인하여 새로운 역할을 가집니다.
-
텍스트 편집기에서
github
인증 커넥터를 엽니다:tctl edit github/github -
github
커넥터를 수정하여teams_to_roles
섹션에teleport-event-handler-impersonator
을 추가합니다.이 역할에 매핑해야 하는 팀은 조직의 역할 기반 액세스 제어(RBAC) 설계에 따라 다릅니다. 그러나 팀은 귀하의 사용자 계정을 포함해야 하며, 조직 내에서 가장 작은 팀이어야 합니다.
예시는 다음과 같습니다:
teams_to_roles: - organization: octocats team: admins roles: - access + - teleport-event-handler-impersonator
-
파일을 편집하고 저장하여 변경 사항을 적용합니다.
-
Teleport 클러스터에서 로그아웃한 후 다시 로그인하여 새로운 역할을 가집니다.
-
saml
구성 리소스를 가져옵니다:tctl get --with-secrets saml/mysaml > saml.yaml--with-secrets
플래그는spec.signing_key_pair.private_key
의 값을saml.yaml
파일에 추가합니다. 이 키는 민감한 값을 포함하므로, 리소스를 업데이트한 후 즉시saml.yaml
파일을 삭제해야 합니다. -
saml.yaml
을 수정하여attributes_to_roles
섹션에teleport-event-handler-impersonator
을 추가합니다.이 역할에 매핑해야 하는 속성은 조직의 역할 기반 액세스 제어(RBAC) 설계에 따라 다릅니다. 그러나 그룹은 귀하의 사용자 계정을 포함해야 하며, 조직 내에서 가장 작은 그룹이어야 합니다.
예시는 다음과 같습니다:
attributes_to_roles: - name: "groups" value: "my-group" roles: - access + - teleport-event-handler-impersonator
-
변경 사항을 적용합니다:
tctl create -f saml.yaml -
Teleport 클러스터에서 로그아웃한 후 다시 로그인하여 새로운 역할을 가집니다.
-
oidc
구성 리소스를 가져옵니다:tctl get oidc/myoidc --with-secrets > oidc.yaml--with-secrets
플래그는spec.signing_key_pair.private_key
의 값을oidc.yaml
파일에 추가합니다. 이 키는 민감한 값을 포함하므로, 리소스를 업데이트한 후 즉시oidc.yaml
파일을 삭제해야 합니다. -
oidc.yaml
을 수정하여claims_to_roles
섹션에teleport-event-handler-impersonator
을 추가합니다.이 역할에 매핑해야 하는 클레임은 조직의 역할 기반 액세스 제어(RBAC) 설계에 따라 다릅니다. 그러나 그룹은 귀하의 사용자 계정을 포함해야 하며, 조직 내에서 가장 작은 그룹이어야 합니다.
예시는 다음과 같습니다:
claims_to_roles: - name: "groups" value: "my-group" roles: - access + - teleport-event-handler-impersonator
-
변경 사항을 적용합니다:
tctl create -f oidc.yaml -
Teleport 클러스터에서 로그아웃한 후 다시 로그인하여 새로운 역할을 가집니다.
이벤트 핸들러 플러그인 사용자에 대한 신원 파일 내보내기
플러그인에 Teleport 신원 파일에 대한 액세스를 부여하십시오. 유출시 덜 위험한 단기 신원 파일을 생성하기 위해 Machine ID를 사용하는 것이 좋지만, 데모 배포에서는 tctl
을 사용하여 더 긴 신원 파일을 생성할 수 있습니다.
tbot
을 구성하여 the plugin 에 필요한 자격 증명을 생성하는 출력을 설정합니다. the plugin 가 Teleport API에 액세스할 것이므로, 사용할 올바른 출력 유형은 identity
입니다.
이 안내서에서는 directory
대상을 사용할 것입니다. 이는 이러한 자격 증명을 디스크의 지정된 디렉토리에 작성합니다. 이 디렉토리는 tbot
이 실행되는 Linux 사용자가 쓸 수 있도록 하여야 하며, the plugin 가 실행되는 Linux 사용자가 읽을 수 있도록 해야 합니다.
tbot
구성을 수정하여 identity
출력을 추가합니다.
Linux 서버에서 tbot
을 실행하는 경우, directory
출력을 사용하여 /opt/machine-id
디렉토리에 신원 파일을 작성합니다:
outputs:
- type: identity
destination:
type: directory
# 이 안내서에서는 /opt/machine-id 를 대상 디렉토리로 사용합니다.
# 이를 사용자 정의할 수 있습니다. 여러 출력은 동일한
# 대상을 공유할 수 없습니다.
path: /opt/machine-id
Kubernetes에서 tbot
을 실행하는 경우, Kubernetes 비밀에 신원 파일을 작성합니다:
outputs:
- type: identity
destination:
type: kubernetes_secret
name: teleport-event-handler-identity
tbot
을 백그라운드 서비스로 운영하는 경우, 이를 재시작합니다. tbot
을 원샷 모드로 실행하는 경우, 지금 실행합니다.
이제 /opt/machine-id
아래에 identity
파일 또는 teleport-event-handler-identity
라는 Kubernetes 비밀이 생성된 것을 볼 수 있습니다. 이 파일에는 the plugin 가 Teleport Auth 서비스에 인증하기 위해 필요한 개인 키와 서명된 인증서가 포함되어 있습니다.
모든 Teleport 사용자와 마찬가지로, teleport-event-handler
는 Teleport 클러스터에 연결하기 위해 서명된 자격 증명이 필요합니다. 이 자격 증명을 요청하기 위해 tctl auth sign
명령을 사용할 것입니다.
다음 tctl auth sign
명령은 teleport-event-handler
사용자로 가장하여 서명된 자격 증명을 생성하고, 로컬 디렉토리에 아이덴티티 파일을 작성합니다:
tctl auth sign --user=teleport-event-handler --out=identity
plugin는 TLS를 통해 Teleport Auth 서비스의 gRPC 엔드포인트에 연결합니다.
아이덴티티 파일인 identity
는 TLS 및 SSH 자격 증명을 모두 포함합니다. plugin는 SSH 자격 증명을 사용하여 Proxy Service에 연결하고, Proxy Service는 Auth Service로의 역 터널 연결을 설정합니다. plugin는 이 역 터널과 TLS 자격 증명을 사용하여 Auth Service의 gRPC 엔드포인트에 연결합니다.
기본적으로 tctl auth sign
은 상대적으로 짧은 수명의 인증서를 생성합니다. 운영 배포를 위해, 우리는 Machine ID를 사용하여 프로그램적으로 인증서를 발급하고 갱신할 것을 제안합니다. 이에 대한 자세한 내용은 Machine ID 시작 가이드를 참조하십시오.
인증서는 기존 자격 증명보다 더 긴 유효 기간을 가질 수 없음을 유의하십시오.
예를 들어, 1000시간 TTL의 인증서를 발급하려면 최소 1000시간 유효한 세션으로 로그인해야 합니다. 이는 사용자가 최소 1000시간 (60000분)의 max_session_ttl
을 허용하는 역할이 있어야 하며, 로그인 시 --ttl
을 지정해야 함을 의미합니다:
tsh login --proxy=teleport.example.com --ttl=60060
리눅스 서버에서 plugin를 실행 중이라면, plugin의 인증서 파일을 보관할 데이터 디렉토리를 생성하십시오:
sudo mkdir -p /var/lib/teleport/api-credentialssudo mv identity /var/lib/teleport/plugins/api-credentials
Kubernetes에서 plugin를 실행 중이라면, Teleport 아이덴티티 파일을 포함하는 Kubernetes 비밀을 생성하십시오:
kubectl -n teleport create secret generic --from-file=identity teleport-event-handler-identity
Teleport 자격 증명이 만료되면, 다시 tctl auth sign
명령을 실행하여 갱신해야 합니다.
5/7 단계. Fluentd 및 S3 플러그인이 포함된 Dockerfile 생성
로그를 Panther에 전송하려면 S3용 Fluentd 출력 플러그인을 사용해야 합니다. 다음 내용을 포함한 Dockerfile
을 생성하십시오:
FROM fluent/fluentd:edge
USER root
RUN fluent-gem install fluent-plugin-s3
USER fluent
Docker 이미지를 빌드합니다:
docker build -t fluentd-s3 .
로컬 테스트 중?
로컬 Docker 컨테이너에서 Fluentd를 테스트하는 경우, 설정을 테스트할 수 있도록 루트 사용자로 대화형 셸로 진입점을 조정할 수 있습니다.
docker run -u $(id -u root):$(id -g root) -p 8888:8888 -v $(pwd):/keys -v \$(pwd)/fluent.conf:/fluentd/etc/fluent.conf --entrypoint=/bin/sh -i --tty fluentd-s3
Panther용 Fluentd 구성
Teleport Event Handler를 실행하면 fluent.conf
파일이 생성됩니다. 이 파일은 Panther에 로그를 전송하도록 업데이트해야 합니다. 즉, 파일에 <filter>
및 <match>
섹션을 추가해야 합니다. 이러한 섹션은 S3로 전송하기 전에 로그를 필터링하고 형식을 지정합니다. record_transformer는 Panther에 적합한 날짜 및 시간 형식을 전송하는 데 중요합니다.
<!--
# 아래 코드는 teleport-event-handler의 4단계에서 자동 생성되므로 주석 처리됩니다.
fluent.conf
이 파일은 Fluentd가 S3로 로그를 전송하기 위한 샘플 구성 파일입니다.
Teleport Event Handler 플러그인에 의해 생성되었습니다.
파일에 <filter> 및 <match> 섹션을 추가하세요.
<source>
@type http
port 8888
<transport tls>
client_cert_auth true
ca_path "/keys/ca.crt"
cert_path "/keys/server.crt"
private_key_path "/keys/server.key"
private_key_passphrase "AUTOGENERATED"
</transport>
<parse>
@type json
json_parser oj
# 이 시간 형식은 Teleport Event Handler에 의해 사용됩니다.
time_type string
time_format %Y-%m-%dT%H:%M:%S
</parse>
# 이벤트 수가 많으면 fluentd가 수집을 실패하기 시작합니다
# 다음 오류 메시지와 함께: buffer space has too many data errors.
# 다음 구성은 재시작 시 데이터 손실을 방지하고
# 기본 fluentd 버퍼 구성의 한계를 극복합니다.
# 이 구성은 선택 사항입니다.
# 자세한 내용은 https://docs.fluentd.org/configuration/buffer-section을 참조하십시오.
<buffer>
@type file
flush_thread_count 8
flush_interval 1s
chunk_limit_size 10M
queue_limit_length 16
retry_max_interval 30
retry_forever true
</buffer>
</source>
-->
<filter test.log>
@type record_transformer
enable_ruby true
<record>
time ${time.utc.strftime("%Y-%m-%dT%H:%M:%SZ")}
</record>
</filter>
<match test.log>
@type s3
aws_key_id REPLACE_aws_access_key
aws_sec_key REPLACE_aws_secret_access_key
s3_bucket REPLACE_s3_bucket
s3_region us-west-2
path teleport/logs
<buffer>
@type file
path /var/log/fluent/buffer/s3-events
timekey 60
timekey_wait 0
timekey_use_utc true
chunk_limit_size 256m
</buffer>
time_slice_format %Y%m%d%H%M%S
<format>
@type json
</format>
</match>
<match session.*>
@type stdout
</match>
Fluentd 컨테이너 시작:
docker run -p 8888:8888 -v $(pwd):/keys -v $(pwd)/fluent.conf:/fluentd/etc/fluent.conf fluentd-s3
이 명령은 Fluentd 컨테이너를 시작하고 Teleport Event Handler가 로그를 전송할 수 있도록 포트 8888을 공개합니다.
6/7단계. Teleport Event Handler 플러그인 실행
Event Handler 구성
이 섹션에서는 환경에 대한 Teleport Event Handler를 구성합니다.
이전에 Fluentd 이벤트 핸들러를 구성하기 위해 teleport-event-handler.toml
이라는 파일을 생성했습니다. 이 파일에는 다음과 유사한 설정이 포함되어 있습니다:
storage = "./storage"
timeout = "10s"
batch = 20
namespace = "default"
# 윈도우 크기는 이벤트 핸들러가 Teleport로부터 이벤트를 요청하는 시간 창의 지속 시간을 구성합니다.
# 기본적으로 24시간으로 설정되어 있습니다.
# 기본 윈도우 크기에 대한 이벤트 백엔드가 이벤트 양을 관리할 수 없는 경우 윈도우 크기를 줄이십시오.
# 윈도우 크기는 Go의 time.ParseDuration에 의해 구문 분석되는 기간 문자열로 지정해야 합니다.
window-size = "24h"
[forward.fluentd]
ca = "/home/bob/event-handler/ca.crt"
cert = "/home/bob/event-handler/client.crt"
key = "/home/bob/event-handler/client.key"
url = "https://fluentd.example.com:8888/test.log"
session-url = "https://fluentd.example.com:8888/session"
[teleport]
addr = "example.teleport.com:443"
identity = "identity"
구성을 수정하여 fluentd.example.com
을 당신의 Fluentd 배포 도메인 이름으로 교체하십시오.
다음 템플릿을 사용하여 teleport-plugin-event-handler-values.yaml
를 생성하십시오:
eventHandler:
storagePath: "./storage"
timeout: "10s"
batch: 20
namespace: "default"
# 윈도우 크기는 이벤트 핸들러가 Teleport로부터 이벤트를 요청하는 시간 창의 지속 시간을 구성합니다.
# 기본적으로 24시간으로 설정되어 있습니다.
# 기본 윈도우 크기에 대한 이벤트 백엔드가 이벤트 양을 관리할 수 없는 경우 윈도우 크기를 줄이십시오.
# 윈도우 크기는 Go의 time.ParseDuration에 의해 구문 분석되는 기간 문자열로 지정해야 합니다.
windowSize: "24h"
teleport:
address: "example.teleport.com:443"
identitySecretName: teleport-event-handler-identity
identitySecretPath: identity
fluentd:
url: "https://fluentd.fluentd.svc.cluster.local/events.log"
sessionUrl: "https://fluentd.fluentd.svc.cluster.local/session.log"
certificate:
secretName: "teleport-event-handler-client-tls"
caPath: "ca.crt"
certPath: "client.crt"
keyPath: "client.key"
persistentVolumeClaim:
enabled: true
다음으로, 구성 파일을 다음과 같이 수정합니다:
addr
: Teleport Proxy Service 또는 Teleport Enterprise Cloud 계정의 호스트 이름과 HTTPS 포트를 포함합니다 (예: teleport.example.com:443
또는 mytenant.teleport.sh:443
).
identity
: 이전에 내보낸 신원 파일의 경로로 이 항목을 채웁니다.
client_key
, client_crt
, root_cas
: 이 구성에서는 사용하지 않으므로 주석 처리합니다.
address
: Teleport Proxy Service 또는 Teleport Enterprise Cloud 테넌트의 호스트 이름과 HTTPS 포트를 포함합니다 (예: teleport.example.com:443
또는 mytenant.teleport.sh:443
).
identitySecretName
: 이전에 생성한 Kubernetes 비밀의 이름으로 identitySecretName
필드를 채웁니다.
identitySecretPath
: Kubernetes 비밀 내에서 신원 파일의 경로로 identitySecretPath
필드를 채웁니다. 위의 지침을 따랐다면, 이는 identity
가 됩니다.
Linux 서버에서 실행되는 tbot
바이너리를 사용하여 이벤트 처리기에 자격 증명을 제공하는 경우, 이벤트 처리기 구성의 identity
값이 tbot
이 생성하도록 구성한 정체성 파일의 경로와 동일해야 합니다, /opt/machine-id/identity
.
Teleport 이벤트 핸들러 시작
Teleport Teleport Event Handler를 시작하려면 아래 지침을 따르십시오.
teleport-event-handler.toml
파일을 리눅스 서버의 /etc
로 복사합니다.
toml
파일 내의 설정을 환경에 맞게 업데이트하십시오. identity
및 storage
와 같은 설정에는 절대 경로를 사용해야 합니다. 사용 중인 파일과 디렉토리는 teleport-event-handler
서비스 실행 중인 시스템 사용자만 접근할 수 있어야 합니다 (예: /var/lib/teleport-event-handler
).
다음으로, 다음 내용을 포함하는 systemd 서비스 정의를 경로 /usr/lib/systemd/system/teleport-event-handler.service
에 생성하십시오:
[Unit]
Description=Teleport Event Handler
After=network.target
[Service]
Type=simple
Restart=always
ExecStart=/usr/local/bin/teleport-event-handler start --config=/etc/teleport-event-handler.toml --teleport-refresh-enabled=true
ExecReload=/bin/kill -HUP $MAINPID
PIDFile=/run/teleport-event-handler.pid
[Install]
WantedBy=multi-user.target
이벤트 핸들러에 단기 자격 증명을 제공하기 위해 Machine ID를 사용하지 않는 경우 --teleport-refresh-enabled true
플래그를 제거할 수 있습니다.
플러그인을 활성화하고 시작하십시오:
sudo systemctl enable teleport-event-handlersudo systemctl start teleport-event-handler
start
명령을 실행할 때 Teleport Event Handler가 이벤트 내보내기를 시작할 시점을 구성할 수 있습니다. 이 예시는 2021년 5월 5일부터 내보내기를 시작할 것입니다:
teleport-event-handler start --config /etc/teleport-event-handler.toml --start-time "2021-05-05T00:00:00Z"
시작 시간은 Teleport Event Handler를 처음 실행할 때만 한 번 결정할 수 있습니다. 나중에 시간 프레임을 변경하려면 핸들러의 구성 파일에 명시된 storage
필드에 있는 플러그인 상태 디렉토리를 제거하십시오.
Teleport Event Handler가 시작되면 스캔되고 전달된 이벤트에 대한 알림이 표시됩니다:
sudo journalctl -u teleport-event-handlerDEBU Event sent id:f19cf375-4da6-4338-bfdc-e38334c60fd1 index:0 ts:2022-09-2118:51:04.849 +0000 UTC type:cert.create event-handler/app.go:140...
워크스테이션에서 다음 명령을 실행하십시오:
helm install teleport-plugin-event-handler teleport/teleport-plugin-event-handler \ --values teleport-plugin-event-handler-values.yaml \ --version 17.0.0-dev
이전에 configure
명령을 실행한 디렉토리로 이동하고 다음 명령을 실행하십시오:
docker run --network host -v `pwd` :/opt/teleport-plugin -w /opt/teleport-plugin public.ecr.aws/gravitational/teleport-plugin-event-handler:17.0.0-dev start --config=teleport-event-handler.toml
이 명령은 이벤트 핸들러 컨테이너를 설정된 host
네트워크에 연결하며, 이는 Docker 호스트 네트워킹 모드를 사용하고 네트워크 격리를 제거하여 이벤트 핸들러가 로컬호스트에서 Fluentd 컨테이너와 통신할 수 있게 합니다.
이제 Panther의 로그 뷰에서 Teleport 클러스터 이벤트를 보고할 수 있어야 합니다.
7/7단계. Panther를 S3에서 로그를 수집하도록 구성하기
로그가 S3로 전송되면, Panther를 구성하여 이를 수집할 수 있습니다. Panther 문서를 따라 S3 버킷을 데이터 소스로 설정하세요.
연결 문제 해결
Teleport 이벤트 핸들러가 Teleport 클러스터에 연결하는 동안 오류 로그를 표시하는 경우, 다음 사항을 확인하세요:
- Teleport 이벤트 핸들러가 Teleport 클러스터에 연결하기 위해 사용하는 인증서가 만기일이 지나지 않았는지 확인하세요. 이는
tctl auth sign
명령의--ttl
플래그 값으로 기본값은 12시간입니다. - Teleport 이벤트 핸들러 구성 파일(
teleport-event-handler.toml
)에 Teleport 프록시 서비스의 올바른 호스트 및 포트를 제공했는지 확인하세요. - Teleport 이벤트 핸들러를 시작하기 전에 FluentD 컨테이너를 시작하세요. 이벤트 핸들러는 시작 시 즉시 FluentD에 연결을 시도합니다.
다음 단계
- 대리인 사용에 대해 더 읽어보세요.
- Panther 탐지, 경고 및 알림에 대해 자세히 알아보세요.
teleport-plugin-event-handler
Helm 차트의 값 파일에서 설정할 수 있는 모든 옵션을 보려면 참조 가이드를 참조하세요.