InfoGrab Docs

Active Directory 인증을 사용한 Microsoft SQL Server용 Amazon RDS를 이용한 데이터베이스 접근

요약

Teleport can provide secure access to Microsoft SQL Server via the Teleport Database Service. In this guide, you will: 이 가이드는 AWS 관리형 Active Directory 인증을 사용하는 SQL Server용 Amazon RDS에 중점을 둡니다.

Teleport can provide secure access to Microsoft SQL Server via the Teleport Database Service. This allows for fine-grained access control through Teleport's RBAC.

In this guide, you will:

  1. Configure your Microsoft SQL Server database with Active Directory authentication.
  2. Add the database to your Teleport cluster.
  3. Connect to the database via Teleport.

이 가이드는 AWS 관리형 Active Directory 인증을 사용하는 SQL Server용 Amazon RDS에 중점을 둡니다.

작동 방식#

Teleport 데이터베이스 서비스는 SQL Server 데이터베이스와 동일한 Active Directory 도메인에 가입하고 Kerberos 프로토콜을 사용하여 SQL Server에 인증합니다. 사용자가 Teleport를 통해 SQL Server에 연결하면 데이터베이스 서비스는 Active Directory에서 서비스 티켓을 얻고, 데이터베이스 사용자의 장기 키를 사용하여 티켓을 복호화한 다음 SQL Server에 연결합니다. 이 시점에서 데이터베이스 서비스는 사용자 트래픽을 데이터베이스로 전달합니다.

SQL Server와 AD 인증을 사용한 데이터베이스 접근

SQL Server와 AD 인증을 사용한 데이터베이스 접근

전제 조건#

  • 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:

  • Active Directory 인증이 활성화된 SQL Server 데이터베이스.
  • 주체 대체 이름(SAN)이 있는 인증서로 구성된 SQL Server 네트워크 리스너.
  • 데이터베이스와 동일한 Active Directory 도메인에 가입된 Windows 컴퓨터.
  • 데이터베이스와 동일한 Active Directory 도메인에 가입된 Linux 노드. 없는 경우 이 가이드에서 가입 단계를 안내합니다.

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/7단계. Teleport 사용자 생성#

Flag Description
--roles List of roles to assign to the user. The builtin access role allows them to connect to any database server registered with Teleport.
--db-users List of database usernames the user will be allowed to use when connecting to the databases. A wildcard allows any user.
--db-names List of logical databases (aka schemas) the user will be allowed to connect to within a database server. A wildcard allows any database.

For more detailed information about database access controls and how to restrict access see RBAC documentation.

2/7단계. Linux 노드를 Active Directory에 가입#

Note

SQL Server 인스턴스와 동일한 Active Directory 도메인에 가입된 Linux 노드가 이미 있는 경우 이 단계를 건너뛸 수 있습니다.

데이터베이스 서비스가 실행될 Linux 노드는 SQL Server 데이터베이스와 동일한 Active Directory 도메인에 가입되어 있어야 합니다.

가입하려면 Linux 노드가 Active Directory 정규화된 도메인 이름을 확인할 수 있어야 합니다. 예를 들어, AWS 관리형 AD의 경우 디렉터리 개요 페이지의 "네트워킹 세부 정보"에 제공된 네임서버를 사용합니다.

필요한 패키지를 설치합니다:

$ sudo apt-get update
$ sudo apt-get -y install sssd realmd krb5-user samba-common packagekit adcli
$ sudo yum -y update
$ sudo yum -y install sssd realmd krb5-workstation samba-common-tools

/etc/krb5.conf를 편집하여 역방향 DNS 해석을 비활성화하고 기본 영역을 설정합니다. [realms] 섹션에 도메인 정의가 포함되어 있고 도메인 컨트롤러를 가리키는 admin_serverkdc 필드가 설정되어 있는지 확인합니다:

[libdefaults]
default_realm = EXAMPLE.COM
rdns = false

[realms]
  EXAMPLE.COM = {
    kdc = example.com
    admin_server = example.com
  }

영역에 가입합니다:

$ sudo realm join -v -U admin@EXAMPLE.COM example.com
...
 * Successfully enrolled machine in realm
Warning

admin@EXAMPLE.COM의 영역 이름은 반드시 대문자여야 합니다. 그렇지 않으면 노드가 가입하지 못할 수 있습니다.

노드가 영역에 가입했는지 확인하려면 realm list 명령을 사용합니다:

$ sudo realm list
example.com
  type: kerberos
  realm-name: EXAMPLE.COM
  domain-name: example.com
  configured: kerberos-member
  server-software: active-directory
  client-software: sssd
  ...

3/7단계. keytab 파일 생성#

Teleport는 SQL Server 인증을 위한 Active Directory의 Kerberos 서비스 티켓을 얻기 위해 keytab 파일이 필요합니다. 이를 생성하는 가장 쉬운 방법은 adutil Linux CLI 유틸리티를 사용하는 것입니다.

Active Directory 도메인에 가입한 Linux 노드에 adutil을 설치합니다:

$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
$ sudo ACCEPT_EULA=Y yum install -y adutil
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repo
$ sudo ACCEPT_EULA=Y yum install -y adutil

kinit 명령을 사용하여 Active Directory에 로그인합니다:

$ kinit admin@EXAMPLE.COM

adutil keytab create 명령을 사용하여 SQL Server 데이터베이스에 연결할 각 Active Directory 사용자에 대한 keytab 항목을 생성합니다:

$ adutil keytab create teleport.keytab alice
$ adutil keytab create teleport.keytab bob

각 사용자의 암호를 입력하라는 메시지가 표시됩니다. 모든 keytab 항목이 동일한 teleport.keytab 파일에 병합됩니다.

서비스 주체 이름 할당

adutil keytab create 명령이 작동하려면 각 사용자 계정에 서비스 주체 이름이 할당되어 있어야 합니다. 그렇지 않으면 명령이 kvno(키 버전 번호)를 확인할 수 없습니다.

사용자에게 할당된 SPN이 있는지 확인하려면 Active Directory 도메인에 가입된 Windows 컴퓨터에서 다음 명령을 실행합니다:

$ setspn -L alice

사용자 계정에 SPN을 할당하려면 다음 명령을 사용합니다:

$ setspn -s user/alice alice

klist 명령을 사용하여 keytab 파일의 항목을 확인할 수 있습니다:

$ klist -ke teleport.keytab
Keytab name: FILE:teleport.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   5 alice@EXAMPLE.COM (aes256-cts-hmac-sha1-96)
   2 bob@EXAMPLE.COM (aes256-cts-hmac-sha1-96)
Warning

인증 실패를 방지하려면 사용자의 암호를 업데이트한 후 keytab 파일을 업데이트해야 합니다.

4/7단계. Teleport 데이터베이스 서비스 설정#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)

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
    
Note

Teleport 데이터베이스 서비스는 SQL Server와 동일한 Active Directory 도메인에 가입된 Linux 서버에서 실행되어야 합니다.

Teleport 데이터베이스 서비스를 구성합니다. --proxy를 Teleport 프록시 서비스 주소로, --uri를 SQL Server 엔드포인트로 업데이트해야 합니다.

$ sudo teleport db configure create \
  -o file \
  --token=/tmp/token \
  --proxy=teleport.example.com:443 \
  --name=sqlserver \
  --protocol=sqlserver \
  --uri=sqlserver.example.com:1433 \
  --ad-keytab-file=/path/to/teleport.keytab \
  --ad-domain=EXAMPLE.COM \
  --ad-spn=MSSQLSvc/sqlserver.example.com:1433 \
  --labels=env=dev

Teleport 데이터베이스 서비스를 구성합니다. --proxy를 Teleport Cloud 테넌트 주소로, --uri를 SQL Server 엔드포인트로 업데이트해야 합니다.

$ sudo teleport db configure create \
  -o file \
  --token=/tmp/token \
  --proxy=mytenant.teleport.sh:443 \
  --name=sqlserver \
  --protocol=sqlserver \
  --uri=sqlserver.example.com:1433 \
  --ad-keytab-file=/path/to/teleport.keytab \
  --ad-domain=EXAMPLE.COM \
  --ad-spn=MSSQLSvc/sqlserver.example.com:1433 \
  --labels=env=dev

Active Directory 매개변수를 제공합니다:

플래그 설명
--ad-keytab-file 위에서 생성한 Kerberos keytab 파일의 경로.
--ad-domain SQL Server가 가입된 Active Directory 도메인(Kerberos 영역).
--ad-spn Kerberos 티켓을 가져올 SQL Server의 서비스 주체 이름.

서비스 주체 이름#

ldapsearch 명령을 사용하여 SQL Server에 등록된 SPN을 확인할 수 있습니다. 일반적으로 MSSQLSvc/<name>.<ad-domain>:<port> 형식을 취합니다.

예를 들어, sqlserver라는 이름의 Amazon RDS SQL Server가 AWS 관리형 Active Directory 도메인 EXAMPLE.COM에 가입되면 다음 SPN이 등록됩니다:

$ ldapsearch -x -h example.com -D admin -W -b DC=example,DC=com servicePrincipalName
...
# EC2AMAZ-4KN05DU, RDS, AWS Reserved, example.com
dn: CN=EC2AMAZ-4KN05DU,OU=RDS,OU=AWS Reserved,DC=example,DC=com
servicePrincipalName: MSSQLSvc/sqlserver-rds.example.com:1433
servicePrincipalName: MSSQLSvc/EC2AMAZ-4KN05DU.example.com:1433
servicePrincipalName: MSSQLSvc/EC2AMAZ-4KN05DU.example.com
...

또는 AD에 가입된 Windows 컴퓨터에서 Active Directory 사용자 및 컴퓨터 대화 상자의 속성 편집기에서 SPN을 조회할 수 있습니다. RDS SQL Server 개체는 일반적으로 AWS Reserved / RDS 경로 아래에 있습니다:

SPN

Tip

속성 편집기 탭이 표시되지 않으면 "보기 > 고급 기능" 토글이 활성화되어 있는지 확인합니다.

5/7단계. 데이터베이스 서비스 시작#

Configure the Teleport Database 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 Database Service.

You can check the status of the Teleport Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

6/7단계. SQL Server AD 사용자 생성#

Note

SQL Server에 이미 Active Directory 로그인이 있는 경우 이 단계를 건너뛸 수 있습니다.

관리자 계정(예: sa)으로 SQL Server에 연결하고 Active Directory 인증을 사용할 로그인을 생성합니다:

master> CREATE LOGIN [EXAMPLE\alice] FROM WINDOWS WITH DEFAULT_DATABASE = [master], DEFAULT_LANGUAGE = [us_english];

7/7단계. 연결#

Teleport 클러스터에 로그인합니다. SQL Server 데이터베이스가 사용 가능한 데이터베이스 목록에 나타나야 합니다:

$ tsh login --proxy=teleport.example.com --user=alice
$ tsh db ls
# Name      Description         Labels
# --------- ------------------- -------
# sqlserver                     env=dev
$ tsh login --proxy=mytenant.teleport.sh --user=alice
$ tsh db ls
# Name      Description         Labels
# --------- ------------------- -------
# sqlserver                     env=dev

데이터베이스의 자격 증명을 검색하고 연결하려면:

$ tsh db connect --db-user=teleport sqlserver

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

$ tsh db logout sqlserver

문제 해결#

인증서 오류#

tsh db connect 오류에 다음 텍스트가 포함되어 있으면 SQL Server에서 사용하는 인증서가 알려진 인증 기관이 아닙니다.

Error message: TLS Handshake failed: x509: certificate signed by unknown authority

이 문제를 해결하려면 다음과 같이 데이터베이스에 CA 구성을 추가할 수 있습니다:

  databases:
  - name: sqlserver
    protocol: sqlserver
    uri: sqlserver.example.com:1433
    ad:
      keytab_file: /path/to/teleport.keytab
      domain: EXAMPLE.COM
      spn: MSSQLSvc/sqlserver.example.com:1433
    static_labels:
      "env": "dev"
+   tls:
+     # 데이터베이스 CA PEM 인증서를 가리키도록 합니다.
+     ca_cert_file: "rdsca.pem"
+     # 데이터베이스 인증서의 CN 필드가 비어 있는 경우 CA만 확인하도록
+     # TLS 모드를 변경해야 합니다.
+     mode: verify-ca

데이터베이스 CA를 획득할 수 없는 경우 구성 tls.mode: "insecure"를 제공하여 TLS 확인을 건너뛸 수 있습니다. 그러나 프로덕션 환경에서는 TLS 확인을 건너뛰지 않는 것을 권장합니다.

다음 단계#

추가 정보#

Active Directory 인증을 사용한 Microsoft SQL Server용 Amazon RDS를 이용한 데이터베이스 접근

원문 보기
요약

Teleport can provide secure access to Microsoft SQL Server via the Teleport Database Service. In this guide, you will: 이 가이드는 AWS 관리형 Active Directory 인증을 사용하는 SQL Server용 Amazon RDS에 중점을 둡니다.

Teleport can provide secure access to Microsoft SQL Server via the Teleport Database Service. This allows for fine-grained access control through Teleport's RBAC.

In this guide, you will:

  1. Configure your Microsoft SQL Server database with Active Directory authentication.
  2. Add the database to your Teleport cluster.
  3. Connect to the database via Teleport.

이 가이드는 AWS 관리형 Active Directory 인증을 사용하는 SQL Server용 Amazon RDS에 중점을 둡니다.

작동 방식#

Teleport 데이터베이스 서비스는 SQL Server 데이터베이스와 동일한 Active Directory 도메인에 가입하고 Kerberos 프로토콜을 사용하여 SQL Server에 인증합니다. 사용자가 Teleport를 통해 SQL Server에 연결하면 데이터베이스 서비스는 Active Directory에서 서비스 티켓을 얻고, 데이터베이스 사용자의 장기 키를 사용하여 티켓을 복호화한 다음 SQL Server에 연결합니다. 이 시점에서 데이터베이스 서비스는 사용자 트래픽을 데이터베이스로 전달합니다.

SQL Server와 AD 인증을 사용한 데이터베이스 접근

SQL Server와 AD 인증을 사용한 데이터베이스 접근

전제 조건#

  • 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:

  • Active Directory 인증이 활성화된 SQL Server 데이터베이스.
  • 주체 대체 이름(SAN)이 있는 인증서로 구성된 SQL Server 네트워크 리스너.
  • 데이터베이스와 동일한 Active Directory 도메인에 가입된 Windows 컴퓨터.
  • 데이터베이스와 동일한 Active Directory 도메인에 가입된 Linux 노드. 없는 경우 이 가이드에서 가입 단계를 안내합니다.

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/7단계. Teleport 사용자 생성#

Flag Description
--roles List of roles to assign to the user. The builtin access role allows them to connect to any database server registered with Teleport.
--db-users List of database usernames the user will be allowed to use when connecting to the databases. A wildcard allows any user.
--db-names List of logical databases (aka schemas) the user will be allowed to connect to within a database server. A wildcard allows any database.

For more detailed information about database access controls and how to restrict access see RBAC documentation.

2/7단계. Linux 노드를 Active Directory에 가입#

Note

SQL Server 인스턴스와 동일한 Active Directory 도메인에 가입된 Linux 노드가 이미 있는 경우 이 단계를 건너뛸 수 있습니다.

데이터베이스 서비스가 실행될 Linux 노드는 SQL Server 데이터베이스와 동일한 Active Directory 도메인에 가입되어 있어야 합니다.

가입하려면 Linux 노드가 Active Directory 정규화된 도메인 이름을 확인할 수 있어야 합니다. 예를 들어, AWS 관리형 AD의 경우 디렉터리 개요 페이지의 "네트워킹 세부 정보"에 제공된 네임서버를 사용합니다.

필요한 패키지를 설치합니다:

$ sudo apt-get update
$ sudo apt-get -y install sssd realmd krb5-user samba-common packagekit adcli
$ sudo yum -y update
$ sudo yum -y install sssd realmd krb5-workstation samba-common-tools

/etc/krb5.conf를 편집하여 역방향 DNS 해석을 비활성화하고 기본 영역을 설정합니다. [realms] 섹션에 도메인 정의가 포함되어 있고 도메인 컨트롤러를 가리키는 admin_serverkdc 필드가 설정되어 있는지 확인합니다:

[libdefaults]
default_realm = EXAMPLE.COM
rdns = false

[realms]
  EXAMPLE.COM = {
    kdc = example.com
    admin_server = example.com
  }

영역에 가입합니다:

$ sudo realm join -v -U admin@EXAMPLE.COM example.com
...
 * Successfully enrolled machine in realm
Warning

admin@EXAMPLE.COM의 영역 이름은 반드시 대문자여야 합니다. 그렇지 않으면 노드가 가입하지 못할 수 있습니다.

노드가 영역에 가입했는지 확인하려면 realm list 명령을 사용합니다:

$ sudo realm list
example.com
  type: kerberos
  realm-name: EXAMPLE.COM
  domain-name: example.com
  configured: kerberos-member
  server-software: active-directory
  client-software: sssd
  ...

3/7단계. keytab 파일 생성#

Teleport는 SQL Server 인증을 위한 Active Directory의 Kerberos 서비스 티켓을 얻기 위해 keytab 파일이 필요합니다. 이를 생성하는 가장 쉬운 방법은 adutil Linux CLI 유틸리티를 사용하는 것입니다.

Active Directory 도메인에 가입한 Linux 노드에 adutil을 설치합니다:

$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
$ curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
$ sudo apt-get update
$ sudo ACCEPT_EULA=Y apt-get install -y adutil
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/8/prod.repo
$ sudo ACCEPT_EULA=Y yum install -y adutil
$ sudo curl -o /etc/yum.repos.d/msprod.repo https://packages.microsoft.com/config/rhel/9/prod.repo
$ sudo ACCEPT_EULA=Y yum install -y adutil

kinit 명령을 사용하여 Active Directory에 로그인합니다:

$ kinit admin@EXAMPLE.COM

adutil keytab create 명령을 사용하여 SQL Server 데이터베이스에 연결할 각 Active Directory 사용자에 대한 keytab 항목을 생성합니다:

$ adutil keytab create teleport.keytab alice
$ adutil keytab create teleport.keytab bob

각 사용자의 암호를 입력하라는 메시지가 표시됩니다. 모든 keytab 항목이 동일한 teleport.keytab 파일에 병합됩니다.

서비스 주체 이름 할당

adutil keytab create 명령이 작동하려면 각 사용자 계정에 서비스 주체 이름이 할당되어 있어야 합니다. 그렇지 않으면 명령이 kvno(키 버전 번호)를 확인할 수 없습니다.

사용자에게 할당된 SPN이 있는지 확인하려면 Active Directory 도메인에 가입된 Windows 컴퓨터에서 다음 명령을 실행합니다:

$ setspn -L alice

사용자 계정에 SPN을 할당하려면 다음 명령을 사용합니다:

$ setspn -s user/alice alice

klist 명령을 사용하여 keytab 파일의 항목을 확인할 수 있습니다:

$ klist -ke teleport.keytab
Keytab name: FILE:teleport.keytab
KVNO Principal
---- --------------------------------------------------------------------------
   5 alice@EXAMPLE.COM (aes256-cts-hmac-sha1-96)
   2 bob@EXAMPLE.COM (aes256-cts-hmac-sha1-96)
Warning

인증 실패를 방지하려면 사용자의 암호를 업데이트한 후 keytab 파일을 업데이트해야 합니다.

4/7단계. Teleport 데이터베이스 서비스 설정#

The Database Service requires a valid join token to join your Teleport cluster. Run the following tctl command and save the token output in /tmp/token on the server that will run the Database Service:

$ tctl tokens add --type=db --format=text
(=presets.tokens.first=)

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
    
Note

Teleport 데이터베이스 서비스는 SQL Server와 동일한 Active Directory 도메인에 가입된 Linux 서버에서 실행되어야 합니다.

Teleport 데이터베이스 서비스를 구성합니다. --proxy를 Teleport 프록시 서비스 주소로, --uri를 SQL Server 엔드포인트로 업데이트해야 합니다.

$ sudo teleport db configure create \
  -o file \
  --token=/tmp/token \
  --proxy=teleport.example.com:443 \
  --name=sqlserver \
  --protocol=sqlserver \
  --uri=sqlserver.example.com:1433 \
  --ad-keytab-file=/path/to/teleport.keytab \
  --ad-domain=EXAMPLE.COM \
  --ad-spn=MSSQLSvc/sqlserver.example.com:1433 \
  --labels=env=dev

Teleport 데이터베이스 서비스를 구성합니다. --proxy를 Teleport Cloud 테넌트 주소로, --uri를 SQL Server 엔드포인트로 업데이트해야 합니다.

$ sudo teleport db configure create \
  -o file \
  --token=/tmp/token \
  --proxy=mytenant.teleport.sh:443 \
  --name=sqlserver \
  --protocol=sqlserver \
  --uri=sqlserver.example.com:1433 \
  --ad-keytab-file=/path/to/teleport.keytab \
  --ad-domain=EXAMPLE.COM \
  --ad-spn=MSSQLSvc/sqlserver.example.com:1433 \
  --labels=env=dev

Active Directory 매개변수를 제공합니다:

플래그 설명
--ad-keytab-file 위에서 생성한 Kerberos keytab 파일의 경로.
--ad-domain SQL Server가 가입된 Active Directory 도메인(Kerberos 영역).
--ad-spn Kerberos 티켓을 가져올 SQL Server의 서비스 주체 이름.

서비스 주체 이름#

ldapsearch 명령을 사용하여 SQL Server에 등록된 SPN을 확인할 수 있습니다. 일반적으로 MSSQLSvc/<name>.<ad-domain>:<port> 형식을 취합니다.

예를 들어, sqlserver라는 이름의 Amazon RDS SQL Server가 AWS 관리형 Active Directory 도메인 EXAMPLE.COM에 가입되면 다음 SPN이 등록됩니다:

$ ldapsearch -x -h example.com -D admin -W -b DC=example,DC=com servicePrincipalName
...
# EC2AMAZ-4KN05DU, RDS, AWS Reserved, example.com
dn: CN=EC2AMAZ-4KN05DU,OU=RDS,OU=AWS Reserved,DC=example,DC=com
servicePrincipalName: MSSQLSvc/sqlserver-rds.example.com:1433
servicePrincipalName: MSSQLSvc/EC2AMAZ-4KN05DU.example.com:1433
servicePrincipalName: MSSQLSvc/EC2AMAZ-4KN05DU.example.com
...

또는 AD에 가입된 Windows 컴퓨터에서 Active Directory 사용자 및 컴퓨터 대화 상자의 속성 편집기에서 SPN을 조회할 수 있습니다. RDS SQL Server 개체는 일반적으로 AWS Reserved / RDS 경로 아래에 있습니다:

SPN

Tip

속성 편집기 탭이 표시되지 않으면 "보기 > 고급 기능" 토글이 활성화되어 있는지 확인합니다.

5/7단계. 데이터베이스 서비스 시작#

Configure the Teleport Database 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 Database Service.

You can check the status of the Teleport Database Service with systemctl status teleport and view its logs with journalctl -fu teleport.

6/7단계. SQL Server AD 사용자 생성#

Note

SQL Server에 이미 Active Directory 로그인이 있는 경우 이 단계를 건너뛸 수 있습니다.

관리자 계정(예: sa)으로 SQL Server에 연결하고 Active Directory 인증을 사용할 로그인을 생성합니다:

master> CREATE LOGIN [EXAMPLE\alice] FROM WINDOWS WITH DEFAULT_DATABASE = [master], DEFAULT_LANGUAGE = [us_english];

7/7단계. 연결#

Teleport 클러스터에 로그인합니다. SQL Server 데이터베이스가 사용 가능한 데이터베이스 목록에 나타나야 합니다:

$ tsh login --proxy=teleport.example.com --user=alice
$ tsh db ls
# Name      Description         Labels
# --------- ------------------- -------
# sqlserver                     env=dev
$ tsh login --proxy=mytenant.teleport.sh --user=alice
$ tsh db ls
# Name      Description         Labels
# --------- ------------------- -------
# sqlserver                     env=dev

데이터베이스의 자격 증명을 검색하고 연결하려면:

$ tsh db connect --db-user=teleport sqlserver

데이터베이스에서 로그아웃하고 자격 증명을 제거하려면:

$ tsh db logout sqlserver

문제 해결#

인증서 오류#

tsh db connect 오류에 다음 텍스트가 포함되어 있으면 SQL Server에서 사용하는 인증서가 알려진 인증 기관이 아닙니다.

Error message: TLS Handshake failed: x509: certificate signed by unknown authority

이 문제를 해결하려면 다음과 같이 데이터베이스에 CA 구성을 추가할 수 있습니다:

  databases:
  - name: sqlserver
    protocol: sqlserver
    uri: sqlserver.example.com:1433
    ad:
      keytab_file: /path/to/teleport.keytab
      domain: EXAMPLE.COM
      spn: MSSQLSvc/sqlserver.example.com:1433
    static_labels:
      "env": "dev"
+   tls:
+     # 데이터베이스 CA PEM 인증서를 가리키도록 합니다.
+     ca_cert_file: "rdsca.pem"
+     # 데이터베이스 인증서의 CN 필드가 비어 있는 경우 CA만 확인하도록
+     # TLS 모드를 변경해야 합니다.
+     mode: verify-ca

데이터베이스 CA를 획득할 수 없는 경우 구성 tls.mode: "insecure"를 제공하여 TLS 확인을 건너뛸 수 있습니다. 그러나 프로덕션 환경에서는 TLS 확인을 건너뛰지 않는 것을 권장합니다.

다음 단계#

추가 정보#