Teleport로 Azure CLI와 API 보호하기
You can use Teleport to manage access to CLI tools that interact with Azure's APIs. The Teleport Application Service installed on an Azure VM uses managed identities to obtain authentication tokens from Azure.
You can use Teleport to manage access to CLI tools that interact with Azure's APIs. This lets you control access to your infrastructure's management APIs using the same RBAC system that you use to protect your infrastructure itself.
이 가이드에서 다음을 수행합니다:
- 사용자 접근을 위한 Azure 관리 ID를 생성하고 VM에 연결합니다.
- Teleport 클러스터에 Azure 앱과 함께 Teleport Application Service를 배포합니다.
- 관리 ID를 수임하고
tsh를 통해az명령을 실행합니다.
작동 방식#
The Teleport Application Service installed on an Azure VM uses managed identities to obtain authentication tokens from Azure. When a user authenticates to Teleport, they can assume one of the respective user-assigned managed identities to execute Azure CLI commands.
You can configure which Teleport users or roles have access to specific Azure identities, giving you control over who can obtain credentials for different levels of access to Azure CLIs.
The Teleport Application Service connects to the Teleport Proxy Service over a reverse tunnel, so you can run the Application Service in a private network and prevent unauthorized access to your organization's Azure identities.
또는, Teleport SAML IdP 기반 통합을 사용하여 Azure Portal 및 CLI 애플리케이션에 대한 접근을 관리할 수 있습니다. 이 방식에서는 사용자가 Azure 포털 및 CLI 도구에 대화형으로 로그인하고, Azure 서비스는 Teleport 사용자 계정을 대신하여 감사 로그에 태그를 지정하여 Teleport 사용자가 Azure와 상호작용하는 방식에 대한 더 많은 가시성을 제공합니다. 이것은 또한 Azure 포털에 대한 접근을 관리하는 유일한 지원 방법입니다.
사전 요구 사항#
-
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:
-
-
워크스테이션에 설치된
azCLI 도구. Teleport의tsh클라이언트는az바이너리를 사용하여 명령을 실행합니다. 운영 체제에azCLI를 설치하는 방법은 Azure 문서를 참조하십시오. -
Teleport Application Service를 실행할 Azure VM. Azure VM은 Linux 배포판을 실행해야 합니다.
Azure Kubernetes Service (AKS)이 가이드는 Microsoft Entra 파드 관리 ID가 활성화된 Azure Kubernetes Service(AKS) 배포에도 적용됩니다. 그러나 파드 관리 ID 기능은 2024년 9월에 지원이 종료될 예정입니다.
Microsoft Entra Workload ID를 사용하여 AKS에서 Teleport Application Service를 실행하려면 Workload ID를 사용한 AKS에서의 Azure CLI 접근을 참조하십시오.
-
사용자 할당 Azure 관리 ID를 생성하고 VM에 연결하는 기능. Azure에서 이 작업을 수행하려면 Azure 계정에 세 가지 역할 할당이 필요합니다: Managed Identity Contributor, Managed Identity Operator, Virtual Machine Contributor.
기존 ID 사용이 가이드에서는 Teleport를 사용한 Azure CLI 접근을 시연하기 위해 사용자 할당 관리 ID를 생성합니다.
Teleport를 통해 Azure CLI 사용자가 수임할 다른 ID가 있다면 그것을 대신 사용할 수 있습니다. 이 경우 Managed Identity Contributor 역할 할당이 필요하지 않습니다.
To check that you can connect to your Teleport cluster, sign in with
tsh login, then verify that you can runtctlcommands 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 statuscommand, you can use your current credentials to run subsequenttctlcommands from your workstation. If you host your own Teleport cluster, you can also runtctlcommands on the computer that hosts the Teleport Auth Service for full permissions.1/4단계. VM에 ID 부여#
이 단계에서는 Azure 관리 ID를 생성하고 Azure VM에 할당합니다. 생성할 ID는
teleport-azure라고 하며, Azure 계정의 리소스를 볼 수 있는 권한을 가집니다.모든 Azure ID 아래에서 Teleport가 Azure CLI에 대한 접근 권한을 부여할 수 있도록 설정할 수 있습니다. 사용하려는 다른 ID가 있다면 새 ID 생성을 건너뛸 수 있습니다.
Azure 관리 ID 생성#
Azure Portal에서 관리 ID 보기를 방문합니다.
Create를 클릭합니다.
Subscription, Resource group, Region 아래에서 VM이 속한 것을 선택합니다.
Name 필드에
teleport-azure를 입력합니다.
Review + create를 클릭한 다음 Create를 클릭합니다.
생성이 완료되면 Go to resource를 클릭합니다. 새 ID 페이지에서 JSON View를 클릭합니다. 오른쪽 사이드바 상단에서 다음과 유사한 값이 있는 Resource ID 필드를 볼 수 있습니다:
/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/teleport-azure이 가이드의 나중에 사용할 수 있도록 이 ID의 URI를 복사합니다.
teleport-azureID에 리소스 보기 권한 허용#Azure ID를 생성한 후, 계정의 리소스에 접근할 수 있도록 권한을 부여합니다. 이 경우 새 Azure ID가 리소스 그룹의 리소스를 볼 수 있도록 권한을 부여합니다.
Azure Portal 검색 상자에 Azure 리소스 그룹 이름을 입력하고 해당 리소스 그룹 페이지를 방문합니다. 왼쪽 탐색 사이드바에서 Access control (IAM) 탭을 클릭합니다. Access control (IAM) 패널 상단의 버튼 행에서 Add > Add role assignment를 클릭합니다.
Add role assignment 화면에서 리소스에 대한 읽기 전용 접근 권한이 있는 기본 제공 역할인 Reader를 클릭합니다.

화면 하단으로 스크롤하여 Next를 클릭합니다.
Members 탭에서 Assign access to 필드에 Managed identity를 선택합니다. Select members를 클릭합니다.
오른쪽 사이드바에서 Managed identity 드롭다운 메뉴를 찾아 User-assigned managed identity를 선택합니다. 이전에 생성한
teleport-azureID를 선택합니다.
Select를 클릭한 다음 Review + assign을 클릭합니다.
Role이 "Reader"이고, Scope가 선택한 리소스 그룹과 일치하며, Members 필드에 이전에 생성한
teleport-azure관리 ID가 포함되어 있는지 확인합니다.Review + assign을 다시 클릭합니다.
Azure VM에 ID 연결#
관리 ID를 생성하고 역할을 할당했으므로, Teleport Application Service가 Azure CLI 트래픽을 프록시하기 위해 ID를 수임할 수 있도록 Azure VM에 ID를 연결합니다.
Azure Portal의 가상 머신 보기에서 Teleport Application Service를 호스팅하는 데 사용하는 VM 이름을 클릭합니다.
오른쪽 패널에서 Identity 탭을 클릭한 다음, Identity 보기 내에서 User assigned 탭을 클릭합니다. +Add를 클릭한 다음
teleport-azureID를 선택합니다. Add를 클릭합니다.
Azure VM 페이지의 Identity 탭으로 다시 이동합니다. User assigned 서브 탭에 새 ID가 목록에 표시되어야 합니다:

2/4단계. Teleport Application Service 배포#
이 단계에서는
teleport-azureID를 할당한 Azure VM에서 Teleport Application Service를 실행합니다.Get a join token#
Establish trust between your Teleport cluster and your new Application Service instance by creating a join token:
$ tctl tokens add --type=app --ttl=1h --format=text (=presets.tokens.first=)Assign to your token and, on the host where you will install the Teleport Application Service, run the following command to create a file called
/tmp/tokenthat consists only of your 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: "teleport.example.com:443" auth_service: enabled: false proxy_service: enabled: false ssh_service: enabled: false app_service: enabled: true apps: - name: azure-cli cloud: Azure/etc/teleport.yaml을 편집하여teleport.example.com:443을 Teleport Proxy Service 또는 Teleport Cloud 테넌트의 호스트 및 포트(예:mytenant.teleport.sh:443)로 교체합니다.app_service필드는 Teleport Application Service를 구성합니다.app_service.apps내의 각 항목은 애플리케이션 구성입니다.이 예에서는
cloud를Azure로 설정하여 Azure CLI 접근을 활성화했습니다. 이 설정이 구성되면, Application Service는 Azure CLI의 사용자 명령을 프록시하여 사용자가 선택한 ID 아래에서 Azure의 API에 대한 접근을 요청합니다. 이는 ID가 Application Service 호스트에 연결된 것 중 하나인 경우 작동합니다.Teleport Application Service 실행#
Configure the Teleport 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 Teleport Application Service.
You can check the status of the Teleport Application Service with
systemctl status teleportand view its logs withjournalctl -fu teleport.3/4단계. 사용자가 Azure CLI에 접근할 수 있도록 설정#
The next step is to authorize your Teleport user to assume an Azure identity and execute Azure CLI commands via Teleport. You will protect access to this identity using Teleport's RBAC system, where a user's roles determine which Azure managed identities (if any) they can access.
There are two approaches you can take to authorize users to access Azure identities.
Approach Description Supported User Types Dynamic A Teleport role includes a template variable that grants a user access to all Azure identities assigned directly to them. Local users, OIDC, SAML Static A Teleport role explicitly specifies the Azure identities a user is allowed to assume. Local users, OIDC, SAML, GitHub Dynamic identities#
If you are using the dynamic approach, the approach you choose depends on whether your Teleport user is a local user or an SSO user:
Static identities#
If you are using static identities, define a role with access to specific Azure identities, which means that Teleport users who assume this role can use those (and only those) identities to execute commands via an Azure CLI.
Create a file called
azure-cli-access.yamlwith the following content:kind: role version: v5 metadata: name: azure-cli-access spec: allow: app_labels: '*': '*' azure_identities: - /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/teleport-azureEdit the identity URI in the
azure_identitiesfield to match the one you copied in Step 1.This role grants a user access to any Teleport-registered application, such as the
azure-cliapplication we defined earlier, and allows that user to assume theteleport-azureidentity you created earlier.Create the role:
$ tctl create -f azure-cli-access.yaml(!docs/pages/includes/create-role-using-web.mdx!)
Denying access to Azure identities
You can define a Teleport role that denies a user access to one or more Azure identities. To do so, assign values to the
azure_identitiesfield within thespec.denysection of aroleresource.For example, this role denies the user access to all Azure identities:
kind: role version: v5 metadata: name: "no-azure-identities" spec: allow: app_labels: '*': '*' deny: azure_identities: - '*'The
no-azure-identitiesrole enables the user to access all registered applications, but makes use of the wildcard character (*) within thedeny.azure_identitiesfield to prevent the user from assuming any Azure identity.Unlike values of
allow.azure_identities, values ofdeny.azure_identitiescan include wildcard expressions in addition to the URIs of specific Azure identities.The Teleport Auth Service gives
denyrules precedence overallowrules when evaluating a user's roles.(!docs/pages/includes/add-role-to-user.mdx role="azure-cli-access"!)
4/4단계. Teleport로 Azure CLI 사용#
Now that you have authorized your Teleport user to assume the
teleport-azureidentity, you can use Teleport to authenticate to Azure's APIs and execute commands against it via theazCLI.List your Azure CLI application#
Verify that your Teleport user can see the
azure-cliapplication you registered earlier:$ tsh apps ls Application Description Type Public Address Labels ----------- ----------- ---- ------------------------------ ------------------- azure-cli HTTP azure-cli.teleport.example.com teleport.dev/originLog in to use an Azure CLI#
Log in to the application, specifying that you would like to assume the
teleport-azureidentity:$ tsh apps login azure-cli --azure-identity teleport-azureThis command validates the value of the
--azure-identityflag against the ones the user is authorized to assume. The value of the flag can either be the full URI of the identity (e.g., the URI you copied earlier in this guide) or the name of the identity, e.g.,teleport-azure.A user can omit the
--azure-identityflag if they are only authorized to access a single Azure identity, but otherwise not including the--azure-identityflag will result in an error.If the command succeeds, you will see information about the user's chosen Azure identity similar to the following:
[ { "environmentName": "AzureCloud", "homeTenantId": "00000000-0000-0000-0000-000000000000", "id": "00000000-0000-0000-0000-000000000000", "isDefault": true, "managedByTenants": [], "name": "Microsoft Azure Sponsorship", "state": "Enabled", "tenantId": "00000000-0000-0000-0000-000000000000", "user": { "assignedIdentityInfo": "MSIResource-/subscriptions/0000000000000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/teleport-azure", "name": "userAssignedIdentity", "type": "servicePrincipal" } } ] Logged into Azure app "azure-cli". Your identity: /subscriptions/0000000000000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/teleport-azure Example Azure CLI command: tsh az vm listExecute Azure CLI commands#
At this point, you can run
azcommands using the Teleport Application Service by prefixing them withtsh. To list VMs running in your Azure resource group, for example, run the following command:$ tsh az vm listUse Azure CLI applications without
tsh#In addition to running
azcommands viatsh, you can grant secure access to any CLI application that executes commands against Azure's APIs.To do this, use
tshto start a local proxy that forwards traffic from your CLI application to the Teleport Application Service. The Application Service uses an Azure managed identity to fetch an authentication token from Azure, which your CLI application uses to authenticate requests to Azure's APIs.To start the local proxy, run the following
tshcommand:$ tsh proxy azureThe command will print the address of the local proxy server along with
exportcommands for assigning environment variables. Azure CLI applications read these variables in order to request an authentication token for Azure's APIs:(!docs/pages/includes/application-access/azure-tsh-proxy-azure-sample.mdx!)
Copy the
exportcommands and paste them into a second terminal. In that terminal, you can now run your Azure CLI application of choice. For example, you can run the following command to list Azure VMs:$ az vm listSince the
azCLI requests an authentication token using theteleport-azureidentity you created earlier, and that identity is authorized to view resources in your resource group, theaz vm listcommand will only list VMs in that resource group.다음 단계#
- 이제 Teleport를 사용하여 Azure CLI 접근을 보호하는 방법을 알았으니, Teleport 사용자가 공격자가 탈취할 수 있는 장기적인 관리자 역할 없이 일시적으로만 Azure 리소스를 관리할 수 있도록 하십시오. 역할 접근 요청 및 접근 요청 플러그인 문서를 참조하십시오.
- Azure 관리 ID 및 사용자 할당 관리 ID 관리 방법에 대한 Azure 문서를 참조하십시오.
azCLI 명령의 전체 목록은 Azure 문서를 참조하십시오.- 이 가이드의 Teleport 역할에서 설명한
internal및external특성이 Teleport에 의해 채워지는 방법에 대한 자세한 내용은 접근 제어 참조를 참조하십시오.
-
-
