AWS EC2 인스턴스 자격 증명 문서를 통한 서비스 참여
이 가이드에서는 EC2 참여 방법을 사용하여 AWS에서 실행 중인 Teleport 프로세스가 어떠한 시크릿도 공유하지 않고 Teleport 클러스터에 참여하도록 구성하는 방법을 설명합니다. EC2 참여 방법은 자체 호스팅 Teleport 배포에서만 사용할 수 있습니다.
이 가이드에서는 EC2 참여 방법을 사용하여 AWS에서 실행 중인 Teleport 프로세스가 어떠한 시크릿도 공유하지 않고 Teleport 클러스터에 참여하도록 구성하는 방법을 설명합니다.
EC2 참여 방법은 자체 호스팅 Teleport 배포에서만 사용할 수 있습니다. 사용 사례에 따라 두 가지 다른 AWS 참여 방법도 이용할 수 있습니다:
- IAM 참여 방법은 IAM 역할이 연결된 EC2 인스턴스와 같이 IAM 자격 증명에 접근할 수 있는 어디서든 실행 중인 모든 Teleport 프로세스에서 사용할 수 있습니다(문서 참조). 특별한 권한이나 IAM 정책이 필요하지 않습니다: 연결된 정책이 없는 IAM 역할로 충분합니다. Teleport Auth Service에는 IAM 자격 증명이 필요하지 않습니다.
- AWS가 서명하지 않은 토큰: AWS에서 실행 중인 Teleport 프로세스가 Teleport 참여 토큰을 통해, 또는 Kubernetes에서 실행 중인 Teleport 프로세스의 경우 서명된 ServiceAccount 토큰을 통해 클러스터에 참여하도록 구성할 수 있습니다. 이 접근 방식은 클라우드 중립적인 방식을 채택하는 경우와 같이 AWS 특정 API에 의존하지 않고 Teleport 프로세스를 클러스터에 참여시킬 때 사용합니다.
동작 방식#
EC2 참여 방법은 EC2 인스턴스에서 실행 중인 모든 Teleport 프로세스에서 사용할 수 있습니다. EC2 인스턴스당 하나의 Teleport 프로세스만 EC2 참여 방법을 사용할 수 있습니다. 프로세스는 EC2 인스턴스 자격 증명 문서를 Teleport Auth Service에 제출합니다.
한편, Teleport Auth Service는 자격 증명 문서가 합법적인 EC2 인스턴스에
속하는지 확인하기 위해 ec2:DescribeInstances 권한이 있는 AWS IAM 자격 증명을
보유합니다. 클러스터에 참여하는 Teleport 프로세스에는 IAM 자격 증명이
필요하지 않습니다.
사전 요구 사항#
-
A running self-hosted 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.
- Teleport 바이너리가 설치된, Teleport 프로세스를 호스팅할 AWS EC2 인스턴스.
호스트에는 기존 데이터 디렉터리(
/var/lib/teleport기본값)가 없어야 합니다. 이 인스턴스가 이전에 Teleport 클러스터에 참여한 적이 있다면 데이터 디렉터리를 삭제하세요.
1/5단계. AWS IAM 자격 증명 설정#
Teleport Auth Service는 클러스터에 참여하려는 EC2 인스턴스가 합법적이고
현재 실행 중인지 확인하기 위해 ec2:DescribeInstances를 호출할 권한이
필요합니다.
IAM 정책 생성#
계정에서 teleport-DescribeInstances-policy라는 이름으로 다음 AWS IAM 정책을
생성하세요:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:DescribeInstances",
"Resource": "*"
}
]
}
IAM 정책 연결#
Teleport Auth Service가 EC2 인스턴스에서 실행 중이고 이미 "Amazon EC2용 IAM
역할"이 연결되어 있다면, 기존 역할에 위의
teleport-DescribeInstances-policy를 추가하세요. 인스턴스에 아직 연결된
역할이 없다면, 위의 정책으로 IAM 역할을 생성하고 Teleport Auth Service를
실행하는 EC2 인스턴스에 연결하세요.
AWS 외부에서 Teleport Auth Service를 실행하는 경우
teleport-DescribeInstances-policy를 Teleport가 인증에 사용할 IAM 사용자에
직접 연결할 수 있습니다.
공유 구성 파일 또는 환경 변수를 통해 Teleport에 IAM 자격 증명을 제공할 수 있습니다. 자세한 내용은 자격 증명 지정하기를 참조하세요.
2/5단계. AWS 참여 토큰 생성#
AWS 계정의 서비스가 Teleport 클러스터에 참여할 수 있도록 Teleport Auth Service에 특별한 동적 토큰을 구성하세요.
내부적으로 서비스는 AWS 참여 토큰에 구성된 허용 규칙과 일치하는 서명된 EC2 인스턴스 자격 증명 문서를 전송하여 AWS 계정에서 실행 중임을 증명합니다.
AWS 계정과 EC2 인스턴스가 실행될 AWS 리전을 지정하는 allow 규칙과 함께
다음 token.yaml을 생성하세요.
# token.yaml
kind: token
version: v2
metadata:
# the token name is not a secret because instances must prove that they are
# running in your AWS account to use this token
name: ec2-token
spec:
# use the minimal set of roles required (e.g. Node, App, Kube, DB, WindowsDesktop)
roles: [Node]
# set the join method allowed for this token
join_method: ec2
# aws_iid_ttl is the amount of time after the EC2 instance is launched during
# which it should be allowed to join the cluster. Use a short TTL to decrease
# the risk of stolen EC2 Instance Identity Documents being used to join your
# cluster.
#
# When launching your first Teleport process using the EC2 join method, you may need to
# temporarily configure a higher `aws_iid_ttl` value so that you have time
# to get Teleport set up and configured. This feature works best once Teleport
# is configured in an EC2 AMI to start automatically on launch.
aws_iid_ttl: 5m
allow:
- aws_account: "111111111111" # your AWS account ID
aws_regions: # use the minimal set of AWS regions required
- us-west-1
- us-west-2
tctl create token.yaml을 실행하여 토큰을 생성하세요.
3/5단계 Teleport 설치#
AWS EC2 인스턴스에 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
4/5단계. 서비스 구성#
EC2 참여 방법은 SSH, Proxy, Kubernetes, 애플리케이션, 데이터베이스 또는 Windows Desktop 서비스를 실행하는 Teleport 프로세스에 사용할 수 있습니다. Teleport 프로세스는 AWS EC2 인스턴스에서 직접 실행되어야 하며 AWS EC2 IMDSv2에 대한 네트워크 접근이 있어야 합니다(대부분의 EC2 인스턴스에서 기본으로 활성화되어 있습니다).
사용자 지정 teleport.yaml 파일로 Teleport 프로세스를 구성하세요. 다음
예시 구성에 표시된 것처럼 2단계에서 생성한 토큰과 일치하는 token_name 및
method: ec2가 포함된 join_params 섹션을 사용하세요:
# /etc/teleport.yaml
version: v3
teleport:
join_params:
token_name: ec2-token
method: ec2
proxy_server: https://teleport.example.com:443
ssh_service:
enabled: true
auth_service:
enabled: false
proxy_service:
enabled: false
5/5단계. Teleport 프로세스 시작#
Teleport 프로세스를 시작하기 전에 데이터 디렉터리( You can check the status of your Teleport instance with 호스트에서 Teleport를 시작하고 클러스터에 연결하고 참여할 수 있는지
확인하세요. 모든 설정이 완료되었습니다! Teleport Auth Service가 실행 중인 계정이 아닌 다른 AWS 계정의 EC2 인스턴스에서
Teleport 프로세스가 참여하려면 Teleport가 각 계정의 IAM 역할을 수임하고 해당
외부 계정에서 EC2 인스턴스가 실행될 각 AWS 계정에서: 1.1단계의 Teleport Auth Service가 실행 중인 계정에서 수임할 수 있는 IAM 역할
AWS IAM 콘솔로 이동하여 역할 생성을 선택하고, "신뢰할 수 있는 엔터티 유형
선택"에서 "다른 AWS 계정"을 선택한 다음 Teleport Auth Service가 실행 중인
계정의 AWS 계정 ID를 입력하세요. 역할에 Teleport Auth Service가 실행 중인 AWS 계정에서: AWS 참여 토큰을 생성할 때, 각 외부 계정에 대한 허용 규칙을 포함하고 외부
/var/lib/teleport
기본값)가 비어 있어야 합니다. 이 Teleport 프로세스가 이전에 다른 방법(예:
토큰 또는 IAM)으로 참여한 적이 있다면 호스트 UUID가 예상되는 이름
(
systemctl status teleport
and view its logs with journalctl -fu teleport.여러 AWS 계정에 대한 EC2 참여 방법 구성#
ec2:DescribeInstances를 호출할 수 있는 권한이 있어야 합니다.
teleport-DescribeInstances-policy를
생성하세요.teleport-DescribeInstances-role을 생성하세요.teleport-DescribeInstances-policy를 연결하세요.
AssumeRole 문이 포함된
teleport-AssumeRole-policy라는 이름의 IAM 정책을 생성하세요:{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::222222222222:role/teleport-DescribeInstances-role"
},
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::333333333333:role/teleport-DescribeInstances-role"
}
]
}
teleport-AssumeRole-policy를 Teleport Auth Service가 자격 증명을 보유한
IAM 역할에 연결하세요(1.2단계 참조).teleport-DescribeInstances-role에 대한 AWS ARN을 지정하세요.# token.yaml
kind: token
version: v2
metadata:
name: ec2-multiaccount-token
spec:
roles: [Node]
aws_iid_ttl: 5m
allow:
- aws_account: "222222222222"
aws_regions:
- us-west-1
- us-west-2
aws_role: "arn:aws:iam::222222222222:role/teleport-DescribeInstances-role"
- aws_account: "333333333333"
aws_regions:
- us-west-1
- us-west-2
aws_role: "arn:aws:iam::333333333333:role/teleport-DescribeInstances-role"
