InfoGrab Docs

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.

이 가이드에서 다음을 수행합니다:

  1. 사용자 접근을 위한 Azure 관리 ID를 생성하고 VM에 연결합니다.
  2. Teleport 클러스터에 Azure 앱과 함께 Teleport Application Service를 배포합니다.
  3. 관리 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 tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and 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')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • 워크스테이션에 설치된 az CLI 도구. Teleport의 tsh 클라이언트는 az 바이너리를 사용하여 명령을 실행합니다. 운영 체제에 az CLI를 설치하는 방법은 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 접근을 참조하십시오.

이 가이드에서는 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 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.

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를 입력합니다.

Azure 관리 ID 생성

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-azure ID에 리소스 보기 권한 허용#

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-azure ID를 선택합니다.

관리 ID 선택

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-azure ID를 선택합니다. Add를 클릭합니다.

VM에 ID 추가

Azure VM 페이지의 Identity 탭으로 다시 이동합니다. User assigned 서브 탭에 새 ID가 목록에 표시되어야 합니다:

ID 추가 확인

2/4단계. Teleport Application Service 배포#

이 단계에서는 teleport-azure ID를 할당한 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/token that consists only of your token:

$ echo  | sudo tee /tmp/token

Teleport 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.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. 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 내의 각 항목은 애플리케이션 구성입니다.

이 예에서는 cloudAzure로 설정하여 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 teleport and view its logs with journalctl -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.yaml with 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-azure

Edit the identity URI in the azure_identities field to match the one you copied in Step 1.

This role grants a user access to any Teleport-registered application, such as the azure-cli application we defined earlier, and allows that user to assume the teleport-azure identity 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_identities field within the spec.deny section of a role resource.

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-identities role enables the user to access all registered applications, but makes use of the wildcard character (*) within the deny.azure_identities field to prevent the user from assuming any Azure identity.

Unlike values of allow.azure_identities, values of deny.azure_identities can include wildcard expressions in addition to the URIs of specific Azure identities.

The Teleport Auth Service gives deny rules precedence over allow rules 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-azure identity, you can use Teleport to authenticate to Azure's APIs and execute commands against it via the az CLI.

List your Azure CLI application#

Verify that your Teleport user can see the azure-cli application you registered earlier:

$ tsh apps ls
Application Description Type Public Address                 Labels
----------- ----------- ---- ------------------------------ -------------------
azure-cli               HTTP azure-cli.teleport.example.com teleport.dev/origin

Log in to use an Azure CLI#

Log in to the application, specifying that you would like to assume the teleport-azure identity:

$ tsh apps login azure-cli --azure-identity teleport-azure

This command validates the value of the --azure-identity flag 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-identity flag if they are only authorized to access a single Azure identity, but otherwise not including the --azure-identity flag 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 list

Execute Azure CLI commands#

At this point, you can run az commands using the Teleport Application Service by prefixing them with tsh. To list VMs running in your Azure resource group, for example, run the following command:

$ tsh az vm list

Use Azure CLI applications without tsh#

In addition to running az commands via tsh, you can grant secure access to any CLI application that executes commands against Azure's APIs.

To do this, use tsh to 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 tsh command:

$ tsh proxy azure 

The command will print the address of the local proxy server along with export commands 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 export commands 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 list

Since the az CLI requests an authentication token using the teleport-azure identity you created earlier, and that identity is authorized to view resources in your resource group, the az vm list command will only list VMs in that resource group.

다음 단계#

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.

이 가이드에서 다음을 수행합니다:

  1. 사용자 접근을 위한 Azure 관리 ID를 생성하고 VM에 연결합니다.
  2. Teleport 클러스터에 Azure 앱과 함께 Teleport Application Service를 배포합니다.
  3. 관리 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 tctl and tsh clients.

    Installing `tctl` and `tsh` clients
    1. Determine the version of your Teleport cluster. The tctl and tsh clients must be at most one major version behind your Teleport cluster version. Send a GET request to the Proxy Service at /v1/webapi/find and 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')"
      
    2. Follow the instructions for your platform to install tctl and tsh clients:

  • 워크스테이션에 설치된 az CLI 도구. Teleport의 tsh 클라이언트는 az 바이너리를 사용하여 명령을 실행합니다. 운영 체제에 az CLI를 설치하는 방법은 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 접근을 참조하십시오.

이 가이드에서는 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 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.

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를 입력합니다.

Azure 관리 ID 생성

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-azure ID에 리소스 보기 권한 허용#

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-azure ID를 선택합니다.

관리 ID 선택

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-azure ID를 선택합니다. Add를 클릭합니다.

VM에 ID 추가

Azure VM 페이지의 Identity 탭으로 다시 이동합니다. User assigned 서브 탭에 새 ID가 목록에 표시되어야 합니다:

ID 추가 확인

2/4단계. Teleport Application Service 배포#

이 단계에서는 teleport-azure ID를 할당한 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/token that consists only of your token:

$ echo  | sudo tee /tmp/token

Teleport 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.

  1. Assign to your Teleport cluster hostname and port, but not the scheme (https://).

  2. 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 내의 각 항목은 애플리케이션 구성입니다.

이 예에서는 cloudAzure로 설정하여 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 teleport and view its logs with journalctl -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.yaml with 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-azure

Edit the identity URI in the azure_identities field to match the one you copied in Step 1.

This role grants a user access to any Teleport-registered application, such as the azure-cli application we defined earlier, and allows that user to assume the teleport-azure identity 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_identities field within the spec.deny section of a role resource.

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-identities role enables the user to access all registered applications, but makes use of the wildcard character (*) within the deny.azure_identities field to prevent the user from assuming any Azure identity.

Unlike values of allow.azure_identities, values of deny.azure_identities can include wildcard expressions in addition to the URIs of specific Azure identities.

The Teleport Auth Service gives deny rules precedence over allow rules 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-azure identity, you can use Teleport to authenticate to Azure's APIs and execute commands against it via the az CLI.

List your Azure CLI application#

Verify that your Teleport user can see the azure-cli application you registered earlier:

$ tsh apps ls
Application Description Type Public Address                 Labels
----------- ----------- ---- ------------------------------ -------------------
azure-cli               HTTP azure-cli.teleport.example.com teleport.dev/origin

Log in to use an Azure CLI#

Log in to the application, specifying that you would like to assume the teleport-azure identity:

$ tsh apps login azure-cli --azure-identity teleport-azure

This command validates the value of the --azure-identity flag 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-identity flag if they are only authorized to access a single Azure identity, but otherwise not including the --azure-identity flag 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 list

Execute Azure CLI commands#

At this point, you can run az commands using the Teleport Application Service by prefixing them with tsh. To list VMs running in your Azure resource group, for example, run the following command:

$ tsh az vm list

Use Azure CLI applications without tsh#

In addition to running az commands via tsh, you can grant secure access to any CLI application that executes commands against Azure's APIs.

To do this, use tsh to 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 tsh command:

$ tsh proxy azure 

The command will print the address of the local proxy server along with export commands 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 export commands 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 list

Since the az CLI requests an authentication token using the teleport-azure identity you created earlier, and that identity is authorized to view resources in your resource group, the az vm list command will only list VMs in that resource group.

다음 단계#