tctl과 함께하는 머신 및 워크로드 아이덴티티
tctl은 Teleport 클러스터 관리 CLI 도구입니다. 이 가이드에서는 tctl용 자격 증명을 생성하도록 tbot을 설정하고, 파일에 정의된 Teleport 역할을 배포하기 위해 tctl을 사용합니다. A running Teleport cluster.
tctl은 Teleport 클러스터 관리 CLI 도구입니다. 일반적으로 로컬에 로그인된 사용자의 자격 증명을 사용하지만, 머신 및 워크로드 아이덴티티가 발급한 자격 증명을 사용하는 것도 가능합니다. 이를 통해 비대화형 환경(예: CI/CD)에 배포된 사용자 지정 자동화 워크플로의 일부로 tctl을 활용할 수 있습니다.
이 가이드에서는 tctl용 자격 증명을 생성하도록 tbot을 설정하고, 파일에 정의된 Teleport 역할을 배포하기 위해 tctl을 사용합니다.
사전 조건#
-
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:
-
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.
tctl을 사용할 머신에tbot이 이미 설치되고 설정되어 있어야 합니다. 자세한 내용은 배포 가이드를 참조하세요.
1단계/3단계. RBAC 설정#
먼저 tbot이 생성한 자격 증명이 Teleport 설정을 수정할 수 있도록 Teleport를 설정해야 합니다. 이는 필요한 권한을 부여하는 역할을 만들고 해당 역할을 봇에 할당하는 방식으로 수행됩니다.
공격의 피해 범위를 제한하기 위해 가능한 한 적은 권한을 부여하는 것이 중요합니다. 이 예시에서는 역할을 만들고 업데이트하는 능력만 부여합니다.
다음 내용으로 role.yaml 파일을 만듭니다:
kind: role
version: v6
metadata:
name: example-role
spec:
allow:
rules:
- resources:
# tctl로 관리할 리소스 이름을 지정합니다.
# 이 가이드에서는 역할만 관리합니다.
- role
verbs:
- create
- read
- update
- delete
- list
example-role을 사용 사례와 관련된 설명적인 이름으로 교체하세요.
tctl create -f ./role.yaml을 사용하여 역할을 만듭니다.
이제 tctl bots update를 사용하여 봇에 역할을 추가합니다. example을 배포 가이드에서 만든 봇의 이름으로, example-role을 방금 만든 역할의 이름으로 교체하세요:
$ tctl bots update example --add-roles example-role
2단계/3단계. tbot 출력 서비스 설정#
이제 tctl에 필요한 자격 증명을 생성할 서비스로 tbot을 설정해야 합니다. tctl이 Teleport API에 접근하므로 사용할 올바른 서비스 유형은 identity입니다.
이 가이드에서는 directory 대상을 사용합니다. 이는 자격 증명을 디스크의 지정된 디렉터리에 기록합니다. tbot이 실행되는 Linux 사용자가 이 디렉터리에 쓸 수 있고 tctl이 실행될 Linux 사용자가 읽을 수 있도록 하세요.
tbot 설정을 수정하여 identity 출력을 추가합니다:
services:
- type: identity
destination:
type: directory
# 이 가이드에서는 /opt/machine-id를 대상 디렉터리로 사용합니다.
# 필요에 따라 커스터마이즈할 수 있습니다. 여러 출력 서비스는
# 동일한 대상을 공유할 수 없습니다.
path: /opt/machine-id
tbot을 백그라운드 서비스로 실행 중인 경우 재시작하세요. 원샷 모드로 실행 중이라면 나중에 Terraform 플랜을 실행하기 전에 실행해야 합니다.
이제 /opt/machine-id 아래에 identity 파일이 표시됩니다. 이 파일에는 tctl이 Teleport Auth Service에 인증하는 데 필요한 개인 키와 서명된 인증서가 포함됩니다.
3단계/3단계. 아이덴티티 출력 서비스와 함께 tctl 사용#
예시로, tctl은 Teleport 역할을 정의하는 YAML 파일 디렉터리를 적용하는 데 사용됩니다. 이 파일들이 버전 제어(예: git)에 저장되고 변경 시 실행된다면 GitOps 스타일로 Teleport 역할을 관리하는 기반이 됩니다.
예시 역할은 Teleport 클러스터 컨텍스트에서 유용하지 않으며 이 가이드를 완료한 후 수정해야 합니다.
roles/ 디렉터리를 만들고 그 안에 example.yaml을 만듭니다:
kind: role
version: v6
metadata:
name: tctl-test
spec:
# 이것은 예시 역할이므로 아무 것도 수행하지 않습니다.
allow: {}
아이덴티티 파일을 사용하도록 tctl을 설정하려면 -i 플래그를 사용합니다. 아이덴티티 파일에 Teleport의 주소가 지정되지 않으므로 Teleport Proxy 또는 Teleport Auth Server의 주소와 함께 --auth-server도 지정해야 합니다.
tctl을 실행하고, example.teleport.sh:443을 Teleport Proxy 또는 Auth Service의 주소로, /opt/machine-id/identity를 수정한 경우 생성된 아이덴티티 파일의 경로로 교체합니다:
$ tctl --auth-server example.teleport.sh:443 -i /opt/machine-id/identity create -f roles/*.yaml
Teleport 클러스터를 확인하여 역할이 만들어졌는지 확인합니다.
$ tctl get role/tctl-test
