Teleport Application Service로 AWS 접근
AWS IAM Roles Anywhere를 사용하는 경우, AWS Console 및 CLI 기반 도구에 대한 접근을 관리하는 권장 방법을 제공하는 해당 가이드를 참조하세요. Teleport로 AWS Management Console과 AWS API를 보호할 수 있습니다.
AWS IAM Roles Anywhere를 사용하는 경우, AWS Console 및 CLI 기반 도구에 대한 접근을 관리하는 권장 방법을 제공하는 해당 가이드를 참조하세요.
Teleport로 AWS Management Console과 AWS API를 보호할 수 있습니다. 이를 통해 Access Requests, Access Lists, ID 잠금과 같은 Teleport 기능으로 AWS 인프라에 대한 접근을 관리할 수 있습니다. 또한 사용자가 싱글 사인온 솔루션으로 인증할 때 자동으로 서로 다른 수준의 AWS 접근을 제공하도록 Teleport를 구성할 수 있습니다.
이 가이드에서 다음을 설명합니다:
- Teleport를 통해 AWS Management Console에 접근.
- Teleport를 통해 AWS Command Line Interface (CLI)에 접근.
- Teleport를 통해 AWS SDK를 사용한 애플리케이션 접근.
작동 방식#
이 설정에서 Teleport Application Service는 하나 이상의 대상 IAM 역할을 맡을 수 있는 AWS IAM 역할을 가지고 있습니다. Teleport 사용자는 Teleport Web UI와 tsh를 통해 AWS Management Console과 API에 접근합니다. 사용자가 AWS Management Console을 방문하거나 AWS 클라이언트 애플리케이션으로 명령을 실행하면 Teleport Application Service가 사용자의 RBAC 권한을 확인하고, 권한이 있으면 사용자의 요청을 AWS로 전달합니다.
사전 요구 사항#
-
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.
-
Teleport Application Service를 실행할 AWS EC2 인스턴스 또는 Elastic Kubernetes Service (EKS) 클러스터. EC2 인스턴스는 Linux 배포판을 실행해야 합니다. 프로덕션 환경에서 이 가이드를 따르기 전에 절차에 익숙해지기 위해 새로운 데모 인스턴스 또는 EKS 클러스터로 시작하는 것을 권장합니다.
-
연결하려는 AWS 계정에서 IAM 역할과 정책을 생성할 권한.
-
PATH에
aws명령줄 인터페이스(CLI) 도구. AWS 설명서를 참조하여 최신 버전의 AWS CLI를 설치하거나 업데이트하세요. -
EKS에서 Teleport Application Service를 실행할 계획이라면 Kubernetes 클러스터에서 IAM OIDC 공급자가 실행 중이어야 합니다. IAM OIDC 공급자 생성 방법은 AWS 설명서를 참조하세요.
클러스터에서 IAM OIDC 공급자가 실행 중인지 확인하려면 다음
aws명령을 실행합니다. 에 EKS 클러스터가 실행 중인 리전을, 에 Kubernetes 클러스터 이름을 지정합니다:$ aws --region= eks describe-cluster --name --query "cluster.identity.oidc.issuer" --output text클러스터와 연관된 IAM OIDC 공급자가 있으면 이 명령이 해당 ID를 출력합니다.
1단계/4단계. AWS IAM 구성#
이 섹션에서는 Teleport Application Service가 AWS API를 프록시할 수 있도록 AWS IAM 리소스를 구성합니다.
이 가이드의 나머지 부분에서는 AWS 관리형 ReadOnlyAccess 정책을 통해 AWS 리소스에 대한 읽기 전용 접근을 허용하는 ExampleReadOnlyAccess라는 IAM 역할에 대한 접근을 보호한다고 가정합니다. 이 가이드를 ExampleReadOnlyAccess 역할로 데모 환경에서 따르고, 절차에 익숙해진 후 프로덕션 AWS 역할을 보호하는 것을 권장합니다.
다음 리소스를 생성합니다:
| 이름 | 리소스 | 기능 |
|---|---|---|
ExampleReadOnlyAccess |
IAM 역할 | Teleport로 접근을 보호할 예시 역할. |
TeleportAWSAccess |
IAM 역할 | Application Service가 사용자 요청을 AWS로 프록시하기 위해 다른 역할을 맡을 수 있도록 허용. |
AssumeRole |
IAM 정책 | Application Service가 사용자 요청을 AWS로 프록시하기 위해 다른 역할을 맡을 수 있도록 허용. |
TeleportAWSAccess (EC2 배포의 경우) |
EC2 인스턴스 프로파일 | TeleportAWSAccess 역할을 EC2 인스턴스와 연결. |
Teleport Application Service용 역할 생성#
이 섹션에서는 Teleport Application Service가 사용자 트래픽을 AWS API로 프록시하기 위해 다른 IAM 역할을 맡을 수 있도록 하는 IAM 역할을 생성합니다.
-
Teleport Application Service가 생성할 역할을 맡을 수 있도록 하는 신뢰 정책을 정의합니다.
app-service-tp.json파일을 생성합니다:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }OIDC 발급자 ID를 검색합니다. 에 EKS 클러스터 이름을, 에 EKS 클러스터가 실행 중인 AWS 리전을 지정합니다:
$ aws --region= eks describe-cluster --name --query "cluster.identity.oidc.issuer" --output text | grep -Eo "[A-Z0-9]+$" AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA다음 내용으로
app-service-tp.json파일을 생성합니다. 에 검색한 발급자 문자열을, 에 EKS 클러스터가 속한 AWS 계정 ID를 지정합니다:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::Assign the
aws-ro-accessrole to your Teleport user by running the appropriate commands for your authentication provider:3단계/4단계. Teleport Application Service 설정#
AWS 및 Teleport에서 RBAC 리소스를 구성했으므로 남은 단계는 Teleport Application Service를 시작하는 것입니다.
조인 토큰 얻기#
조인 토큰을 생성하여 Teleport 클러스터와 새 Application Service 인스턴스 간의 신뢰를 설정합니다:
$ tctl tokens add --type=app --ttl=1h --format=text (=presets.tokens.first=)Teleport Application Service를 설치할 호스트에서 토큰만으로 구성된
/tmp/token파일을 생성합니다. 에 토큰 값을 지정합니다:$ echo | sudo tee /tmp/tokenTeleport Application Service 설치#
Teleport Application Service를 설치할 호스트에서 다음 명령을 실행합니다:
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
Teleport Application Service 구성#
-
Teleport Application Service를 실행할 호스트에서 다음 내용으로
/etc/teleport.yaml파일을 생성합니다:version: v3 teleport: join_params: token_name: "/tmp/token" method: token proxy_server: "Have multiple sources of AWS credentials?
Teleport's AWS client loads credentials from different sources in the following order:
- Environment Variables
- Shared credentials file
- Shared configuration file (Teleport always enables shared configuration)
- EC2 Instance Metadata (credentials only)
While you can provide AWS credentials via a shared credentials file or shared configuration file, you will need to run the Application Service with the
AWS_PROFILEenvironment variable assigned to the name of your profile of choice.If you have a specific use case that the instructions above do not account for, consult the documentation for the AWS SDK for Go for a detailed description of credential loading behavior.
Configure the Application Service to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed the Application Service.
You can check the status of the Application Service with
systemctl status teleportand view its logs withjournalctl -fu teleport.비표준 AWS 리전AWS GovCloud (US) 리전 및 AWS 중국 리전과 같은 비표준 AWS 리전의 경우
AWS_REGION환경 변수 또는 AWS 자격 증명 파일에서 해당 리전을 설정하여 Application Service가 올바른 STS 엔드포인트를 사용할 수 있도록 합니다.4단계/4단계. AWS 리소스 접근#
Teleport Application Service를 AWS에 대한 요청을 프록시하도록 구성했으므로 이제 사용자가 Teleport를 통해 AWS 리소스에 접근할 수 있습니다.
AWS 콘솔 접근#
-
Teleport Web UI 홈 페이지를 방문하여 Resources를 클릭합니다. Teleport Application Service가 예상대로 AWS Management Console을 프록시하고 있으면 Web UI에 등록한 애플리케이션 이름이 표시됩니다. 이 가이드에서는
awsconsole이라고 가정합니다. (리소스가 너무 많아 한 번에 모두 볼 수 없는 경우 검색 상자에 애플리케이션 이름을 입력하세요.) -
AWS Console 애플리케이션의 Launch 버튼을 클릭한 다음 AWS Console에 로그인할 때 맡을 역할을 클릭합니다:

-
AWS Management Console로 리디렉션되어 선택한 역할로 로그인됩니다. AWS Console 오른쪽 상단 모서리에
ExampleReadOnlyRole에 할당된 페더레이션 로그인으로 Teleport 사용자 이름이 표시됩니다:
AWS CLI 접근#
-
데스크톱에서 이 가이드를 따라 구성한 AWS Management Console 앱에 로그인합니다:
$ tsh apps login --aws-role ExampleReadOnlyAccess awsconsole Logged into AWS app "awsconsole". Your IAM role: arn:aws:iam::000000000000:role/ExampleReadOnlyAccess Example AWS CLI command: tsh aws s3 ls Or start a local proxy: tsh proxy aws --app awsconsole--aws-role플래그를 사용하면 AWS API에 접근할 때 맡을 AWS IAM 역할을 지정할 수 있습니다.--aws-role ExampleReadOnlyAccess와 같이 역할 이름을 제공하거나arn:aws:iam::0000000000:role/ExampleReadOnlyAccess와 같이 전체 역할 ARN을 제공할 수 있습니다. -
이제 기본
aws명령줄 도구처럼tsh aws명령을 사용할 수 있습니다:$ tsh aws s3 ls -
다음 명령을 실행하여 AWS 애플리케이션에서 로그아웃하고 자격 증명을 제거합니다:
$ tsh apps logout awsconsole
AWS SDK를 사용한 애플리케이션 접근#
-
데스크톱에서 이 가이드를 따라 구성한 AWS Management Console 앱에 로그인합니다:
$ tsh apps login --aws-role ExampleReadOnlyAccess awsconsole -
새 터미널을 열고 다음 명령을 사용하여 AWS API 트래픽을 Teleport Application Service로 전달하는 로컬 HTTPS 프록시 서버를 시작합니다. 포그라운드에서 실행되므로 터미널을 열어 두세요:
$ tsh proxy aws -p 23456 Started AWS proxy on http://127.0.0.1:23456. Use the following credentials and HTTPS proxy setting to connect to the proxy: export AWS_ACCESS_KEY_ID=(=aws.aws_access_key=) export AWS_SECRET_ACCESS_KEY=(=aws.aws_secret_access_key=) export AWS_CA_BUNDLE=<ca-bundle-path> export HTTPS_PROXY=http://127.0.0.1:23456 -
터미널에서
export명령을 복사하여 새 터미널 창에 붙여넣습니다. -
그런 다음 AWS SDK를 사용하여 로컬 프록시를 통해 AWS API와 통신하는 애플리케이션을 실행할 수 있습니다. 예를 들어, Python 콘솔을 열고
boto3클라이언트를 사용하여 AWS 계정의 EC2 인스턴스를 가져옵니다:>>> import boto3 >>> ec2 = boto3.resource('ec2') >>> for instance in ec2.instances.all(): ... print(instance.id) ...애플리케이션에 대해 AWS 자격 증명 및 HTTPS 프록시 설정을 구성하는 방법을 확인하는 것이 중요합니다. 예를 들어,
terraform및eksctl과 같은 명령줄 도구는 위와 같이 환경 변수를 사용하여 AWS 자격 증명 및 HTTPS 프록시를 설정하는 것을 지원합니다.그러나 일부 AWS SDK는 추가 환경 변수가 필요할 수 있으며(예: AWS SDK for Go v2의 경우
AWS_SDK_LOAD_CONFIG=true) 코드를 통해 HTTPS 프록시를 구성해야 할 수 있습니다(예: AWS SDK for JavaScript). -
AWS 애플리케이션에서 로그아웃하고 자격 증명을 제거하려면:
$ tsh apps logout awsconsole
CloudTrail을 사용하여 Teleport 사용자 활동 보기#
페더레이션 세션의 CloudTrail 이벤트를 보려면 CloudTrail 대시보드로 이동하여 "Event history"로 이동합니다.
각 Teleport 페더레이션 로그인 세션은 Teleport 사용자 이름을 페더레이션 사용자 이름으로 사용하므로, 이를 검색하여 이벤트 기록을 얻을 수 있습니다:

문제 해결#
이 가이드를 따르다가 문제가 발생하면 이 섹션을 참조하세요.
Web UI에서
Internal Server Error또는 연결 실패#Teleport Web UI에서 AWS Management Console을 방문할 때 AWS Management Console 대신
InternalServer Error메시지나 다른 연결 문제가 발생할 수 있습니다.이런 경우 Teleport Application Service 로그를 확인합니다:
Teleport Application Service가 실행 중인 EC2 인스턴스에서 다음 명령을 실행합니다:
$ journalctl -u teleport$ kubectl -n teleport-agent logs statefulset/teleport-kube-agentTeleport Application Service가 AWS API에 요청을 보낼 때 오류가 발생하면 로그에 오류 메시지 스택 추적이 표시됩니다.
로그에서
sts.amazonaws.com:443에 대한 i/o 타임아웃과 같은 연결 실패가 발생할 수 있습니다. Teleport Application Service는 권한이 있는 AWS 콘솔 세션을 생성하기 위해https://sts.amazonaws.com및https://signin.aws.amazon.com/federation에 연결할 수 있어야 합니다.Application Service가 역할을 맡을 권한 없음#
사용자가 AWS에 접근하려고 할 때 Teleport Application Service가
ExampleReadOnlyAccess역할을 맡지 못하면 서비스 로그에 다음과 유사한 오류 메시지가 표시됩니다:AccessDenied: User: arn:aws:sts::000000000000:assumed-role/ROLE_NAME is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::000000000000:role/ExampleReadOnlyAccessAccessDenied메시지에는sts:AssumeRole작업을 실행하기 위해 Teleport Application Service가 맡은 주체가 포함됩니다.주체가
TeleportAWSAccess역할이라면ExampleReadOnlyAccess역할의 신뢰 정책에 해당 주체가 포함되어 있는지 확인합니다.그렇지 않으면 Teleport Application Service가 예상대로
TeleportAWSAccess역할을 맡지 않고 있습니다. Teleport Application Service에 역할 연결 지침을 따릅니다.SSM 세션 중
remote error: tls: bad certificate오류#tsh aws ssm start-session또는tsh aws ecs execute-command명령을 사용하여 System Session Manager (SSM) 세션을 시작할 때remote error: tls: bad certificate오류가 발생할 수 있습니다.이 문제는
tsh가 SSM이 전송하는 WebSocket 연결을 제대로 프록시할 수 없기 때문입니다.tsh aws ssm start-session및tsh aws ecs execute-command에 대한 해결 방법이 구현된 최신 버전의tsh로 업그레이드하세요.tsh해결 방법에 대한 자세한 내용은 이를 도입한 pull requests를 참조하세요:- https://github.com/gravitational/teleport/pull/30510
- https://github.com/gravitational/teleport/pull/33705
tsh proxy aws를 사용하거나tsh버전에 위의 수정 사항이 포함되어 있지 않은 경우, WebSocket 연결이tsh를 우회하도록tsh명령을 실행하기 전에NO_PROXY환경 변수에 다음 도메인을 추가합니다:export NO_PROXY=ssmmessages.us-west-1.amazonaws.comus-west-1을 접근 중인 AWS 리전으로 교체합니다.Management Console이 한 시간 후 만료#
기본적으로 AWS Management Console 세션은 Teleport 웹 세션이 만료될 때까지 지속되며 최대 세션 기간은 12시간입니다. Teleport 역할의
max_session_ttl매개 변수를 수정하여 Teleport 세션 기간을 조정할 수 있습니다.그러나 AWS IAM 역할 체이닝의 제한으로 인해 Teleport가 임시 보안 자격 증명으로 실행 중인 경우 Management Console 세션이 한 시간으로 제한됩니다.
예를 들어, Teleport Application Service가 서비스 계정용 IAM 역할(IRSA)이 있는 EKS에 배포되거나, Teleport Application Services가 웹 또는 SSO 신원을 맡는 경우 AWS Management Console 세션이 한 시간으로 제한됩니다.
이런 경우 EC2 인스턴스에 Application Service를 배포하고 IAM 역할을 연결하는 것이 권장됩니다.
No credential providers error#
If you see the error
NoCredentialProviders: no valid providers in chainin Application Service logs then Teleport is not detecting the required credentials to connect via AWS IAM permissions. Check whether the credentials or security role has been applied in the machine running the Teleport Application Service.When running on EKS, this error may occur if the Teleport Application Service cannot access IMDSv2 when the PUT requests hop limit on the worker node instance is set to 1. You can use the following commands to check the hop limit:
$ aws ec2 describe-instances --instance-ids <node-instance-id> | grep HttpPutResponseHopLimit "HttpPutResponseHopLimit": 1,See IMDSv2 support for EKS and EKS best practices for more details.
누락된 X-Forwarded-Host HTTP 헤더#
tsh로컬 프록시에 요청할 때proxied requests must include X-Forwarded-Host header오류가 발생할 수 있습니다. 이는 Teleport가 유효한 AWS 엔드포인트를 포함하는X-Forwarded-Host헤더를 HTTP 요청에 포함할 것을 기대하기 때문입니다.Teleport AWS 로컬 프록시를 사용하는 애플리케이션이 HTTPS 프록시 설정을 지원하는지 확인하세요. 로컬 프록시 주소를 AWS 엔드포인트 URL로 애플리케이션에 전달하는 것은 더 이상 지원되지 않습니다.
이전에
tsh proxy aws명령에서--endpoint-url플래그를 사용했다면 로컬 HTTPS 프록시를 사용하도록 애플리케이션을 업데이트해야 합니다.다음 단계#
이제 AWS Management Console 및 API에 대한 접근을 보호하도록 Teleport를 설정하는 방법을 알았으므로 조직의 필요에 맞게 설정을 조정할 수 있습니다.
AWS IAM 역할 매핑 세분화#
aws_role_arns필드는 사용자가 Teleport에 인증할 때 동적으로 채울 수 있도록 템플릿 변수를 지원합니다.예를 들어, ID 공급자를 구성하여
aws_role_arns라는 SAML 속성 또는 OIDC 클레임을 정의한 다음, 이 필드를 사용하여 IdP에서 각 사용자가 허용된 AWS 역할 ARN을 나열할 수 있습니다. Teleport 역할에서{{external.aws_role_arns}}변수를 언급하면 Auth Service가 IdP의 데이터를 기반으로 사용자의 허용된 ARN을 채웁니다:aws_role_arns: - {{external.aws_role_arns}}aws_role_arns필드에서 사용할 수 있는 모든 변수 및 함수는 Access Controls 참조를 참조하세요.AWS 애플리케이션 동적 등록#
Teleport Application Service를 실행하는 Teleport Agent 풀을 배포한 다음 Teleport 클러스터에 AWS 애플리케이션을 동적 리소스로 등록할 수 있습니다. 애플리케이션 동적 등록에 대해 자세히 읽어보세요.
대체 에이전트 조인 방법 선택#
이 가이드에서는 조인 토큰 방법을 사용하여 클러스터에 Teleport Application Service를 등록하는 방법을 보여줍니다. 이것은 사용 가능한 여러 방법 중 하나이며, 환경에 가장 적합한 방법을 구성하려면 Teleport 클러스터에 서비스 조인 가이드를 읽는 것을 권장합니다.
추가 읽기#
-
