서버 액세스 시작하기 가이드
서버에서 Teleport SSH Service를 실행하고 Teleport 클러스터에 등록하면 해당 서버를 Teleport로 보호할 수 있습니다. 이 가이드에서는 다음 방법을 안내합니다: Teleport SSH Service는 Teleport Proxy Service로 역방향 SSH 터널을 열고, SSH 클라이언트 트래픽이 이 터널을 통해 서버에 연결됩니다.
서버에서 Teleport SSH Service를 실행하고 Teleport 클러스터에 등록하면 해당 서버를 Teleport로 보호할 수 있습니다.
이 가이드에서는 다음 방법을 안내합니다:
- 서버를 Teleport 클러스터에 등록하기.
- Teleport를 사용하여 서버에 SSH 접속하기.
- Teleport 명령어로 클러스터의 서버 리소스 검사하기.
작동 방식#
Teleport SSH Service는 Teleport Proxy Service로 역방향 SSH 터널을 열고, SSH 클라이언트 트래픽이 이 터널을 통해 서버에 연결됩니다. 이 설정은 배스천 패턴과 유사합니다.
서버가 클러스터에 참여하면 Teleport RBAC 시스템이 서버에 대한 안전한 접근을 강제하고, 관리자는 Teleport 감사 로그를 통해 보안 위협을 파악할 수 있습니다.
Teleport를 사용하여 Kubernetes 노드에 안전하게 접근할 수 있습니다. 이를 위해 이 가이드의 지침에 따라 Teleport SSH Service를 설치하고 실행하도록 노드의 머신 이미지를 수정합니다. SSH Service를 Kubernetes 파드로 실행하지 마십시오. SSH Service 파드가 사용자가 접근하려는 서버에서 실행 중이라는 보장이 없습니다.
소스 코드 보기
architecture-beta
group priv(carbon-virtual-private-cloud)[Private Network]
group priv2(carbon-virtual-private-cloud)[Teleport Cloud or Private Network]
group server(carbon-bare-metal-server)[Linux Server] in priv
service audit_log(carbon-ibm-db2)[Teleport Audit Log] in priv2
service auth(teleport-logo-purple)[Teleport Auth Service] in priv2
service client(carbon-user)[SSH Client]
service proxy(teleport-logo-purple)[Teleport Proxy Service]
service ssh_service(teleport-logo-purple)[Teleport SSH Service] in server
ssh_service:L --> R:proxy
client:R --> L:proxy
proxy:B <--> T:auth
auth:R --> L:audit_log</code></pre></details></div>
사전 요구사항#
-
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
-
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')"
-
Follow the instructions for your platform to install tctl and tsh clients:
- Linux 환경(Amazon Linux, Ubuntu, CentOS Stream, Debian 등)을 실행하는 호스트 하나. 이 호스트가 Teleport 노드로 사용됩니다.
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.
Best practices for production security
When running Teleport in production, you should adhere to the following best
practices to avoid security incidents:
- Avoid using
sudo in production environments unless it's necessary.
- Create new, non-root, users and use test instances for experimenting with Teleport.
- Run Teleport's services as a non-root user unless required. Only the SSH
Service requires root access. Note that you will need root permissions (or
the
CAP_NET_BIND_SERVICE capability) to make Teleport listen on a port
numbered < 1024 (e.g. 443).
- Follow the principle of least privilege. Don't give users
permissive roles when more a restrictive role will do.
For example, don't assign users the built-in
access,editor roles, which give
them permissions to access and edit all cluster resources. Instead, define roles
with the minimum required permissions for each user and configure
Access Requests to provide temporary elevated permissions.
- When you enroll Teleport resources—for example, new databases or applications—you
should save the invitation token to a file.
If you enter the token directly on the command line, a malicious user could view
it by running the
history command on a compromised system.
You should note that these practices aren't necessarily reflected in the examples used
in documentation. Examples in the documentation are primarily intended for demonstration
and for development environments.
1단계/4단계. Linux 호스트에 Teleport 설치#
-
Linux 호스트는 프라이빗 리소스가 됩니다. 초기 접근, 구성 및 인스턴스 프로비저닝을 위해 포트 22를 열어 두십시오.
인스턴스를 구성하고 실행한 다음, tsh 도구와 SSH 모드의 Teleport를 사용하는 방법을 보여드리겠습니다.
-
Teleport SSH Service를 실행할 호스트에서 환경에 맞는 지침에 따라 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
다음으로, Teleport SSH Service를 시작하고 클러스터에 추가하기 위한 조인 토큰을 생성합니다.
2단계/4단계. 클러스터에 서버 추가#
조인 토큰 생성#
로컬 워크스테이션에서 서버를 Teleport 클러스터에 추가하기 위한 조인 토큰을 생성합니다:
Let's save the token to a file
$ tctl tokens add --type=node --format=text > token.file
--type=node는 Teleport 프로세스가 SSH 서버로 동작하여 참여함을 지정합니다.
> token.file은 출력을 token.file이라는 파일에 저장하겠다는 의미입니다.
팁
이는 동적으로 생성되더라도 토큰의 직접 공유를 최소화하는 데 도움이 됩니다.
서버를 클러스터에 참여시키기#
서버에서 token.file을 적절하고 안전한 디렉터리(읽기 권한이 있는 위치)에 저장합니다. 다음으로 Teleport의 SSH Service를 활성화하는 구성 파일을 생성합니다.
tele.example.com을 Teleport Proxy Service의 주소로 변경합니다. --token 플래그에는 token.file을 저장한 경로를 지정합니다.
# Generate config
$ sudo teleport node configure \
--output=file:///etc/teleport.yaml \
--token=/path/to/token.file \
--proxy=tele.example.com:443
mytenant.teleport.sh를 Teleport Cloud 테넌트 주소로 변경합니다. --token 플래그에는 token.file을 저장한 경로를 지정합니다.
# Generate config
$ sudo teleport node configure \
--output=file:///etc/teleport.yaml \
--token=/path/to/token.file \
--proxy=mytenant.teleport.sh:443
위의 teleport node configure 명령은 /etc/teleport.yaml에 구성 파일을 생성합니다. 마지막 단계는 이 구성을 사용하여 Teleport를 시작하는 것입니다:
Configure the Teleport SSH 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 SSH Service.
You can check the status of the Teleport SSH Service with systemctl status teleport
and view its logs with journalctl -fu teleport.
Web UI 접근#
Teleport Web UI에 접근할 수 있는 로컬 사용자를 생성하려면 다음 명령을 실행합니다:
$ tctl users add myuser --roles=editor,access --logins=root,ubuntu,ec2-user
이 명령은 myuser의 비밀번호를 설정하고 다단계 인증을 구성할 수 있는 초기 로그인 링크를 생성합니다.
참고
최소 권한 원칙에 따라 myuser에게는 editor와 access 역할만 부여했습니다.
myuser로 로그인하면 Teleport Web UI에서 서버를 확인할 수 있습니다:

3단계/4단계. 서버에 SSH 접속#
클러스터가 실행 중이므로 이제 서버에 쉽게 연결하는 방법을 살펴보겠습니다.
tsh를 사용하여 클러스터에 SSH 접속할 수 있습니다:
클러스터 로그인#
로컬 머신에서 tsh를 통해 클러스터에 로그인합니다. --proxy 플래그에 Teleport Proxy Service의 주소를 지정합니다:
# Log in through tsh
$ tsh login --proxy=tele.example.com --user=myuser
로컬 머신에서 tsh를 통해 클러스터에 로그인합니다. --proxy 플래그에 Teleport Cloud 테넌트 주소를 지정합니다:
# Log in through tsh
$ tsh login --proxy=mytenant.teleport.sh:443 --user=myuser
이전에 설정한 비밀번호와 인증 요소를 입력하라는 메시지가 표시됩니다.
myuser는 다음과 유사한 출력을 보게 됩니다:
> Profile URL: https://tele.example.com:443
Logged in as: myuser
Cluster: tele.example.com
Roles: access, editor
Logins: root, ubuntu, ec2-user
Kubernetes: disabled
Valid until: 2021-04-30 06:39:13 -0500 CDT [valid for 12h0m0s]
Extensions: permit-agent-forwarding, permit-port-forwarding, permit-pty
이 예시에서 myuser는 이제 Teleport SSH를 통해 tele.example.com 클러스터에 로그인되었습니다.
> Profile URL: https://mytenant.teleport.sh:443
Logged in as: myuser
Cluster: mytenant.teleport.sh
Roles: access, editor
Logins: root, ubuntu, ec2-user
Kubernetes: disabled
Valid until: 2021-04-30 06:39:13 -0500 CDT [valid for 12h0m0s]
Extensions: permit-agent-forwarding, permit-port-forwarding, permit-pty
이 예시에서 myuser는 이제 Teleport SSH를 통해 mytenant.teleport.sh 클러스터에 로그인되었습니다.
클러스터 리소스 표시#
myuser는 SSH 연결 설정에 사용되는 클러스터 서버 이름을 확인하기 위해 다음 명령을 실행할 수 있습니다:
# Display cluster resources
$ tsh ls
이 예시에서 배스천 호스트는 아래 마지막 줄에 위치합니다:
Node Name Address Labels
---------------- -------------- --------------------------------------
ip-172-31-35-170 ⟵ Tunnel
ip-172-31-41-144 127.0.0.1:3022 env=example, hostname=ip-172-31-41-144
서버 연결#
myuser는 로컬에서 다음 명령을 실행하여 배스천 호스트 서버에 SSH 접속할 수 있습니다:
# Use tsh to ssh into a server
$ tsh ssh root@ip-172-31-41-144
이제 다음 작업이 가능합니다:
tsh ssh 명령에서 적절한 IP 주소를 사용하여 클러스터의 다른 서버에 연결.
- Linux 파일 시스템 탐색.
- 원하는 명령 실행.
myuser가 실행한 모든 명령은 기록되며 Teleport Web UI에서 재생할 수 있습니다.
tsh ssh 명령을 통해 사용자는 서드파티 도구로 서버에 SSH 접속하는 것과 동일한 작업을 할 수 있습니다. 두 명령을 비교해 보세요:
$ tsh ssh root@ip-172-31-41-144
ssh 클라이언트를 사용하려면 SSH 구성 파일을 생성하고 노드 이름 뒤에 클러스터 이름을 붙입니다.
$ tsh config > ssh_config_teleport
$ ssh -F ssh_config_teleport root@ip-172-31-41-144.example.teleport.sh
4단계/4단계. tsh와 통합 리소스 카탈로그로 클러스터 검사하기#
이제 myuser는 클러스터 내 다른 서버에 SSH 접속하고, Linux 파일 시스템을 탐색하며, 명령을 실행할 수 있습니다.
- 정의된 역할에 따라 클러스터 내 모든 리소스에 대한 가시성을 가집니다.
- 특정 레이블이 할당된 서버나 서버 그룹을 빠르게 조회할 수 있습니다.
통합 리소스 카탈로그 표시#
배스천 호스트 콘솔에서 다음 명령을 실행합니다:
# List servers
$ tctl nodes ls
이 명령은 쿼리된 모든 리소스를 하나의 뷰로 표시하는 통합 리소스 카탈로그를 보여줍니다:
Nodename UUID Address Labels
---------------- ------------------------------------ -------------- -------------------------------------
ip-172-31-35-170 4980899c-d260-414f-9aea-874feef71747
ip-172-31-41-144 f3d2a65f-3fa7-451d-b516-68d189ff9ae5 127.0.0.1:3022 env=example,hostname=ip-172-31-41-144
가장 오른쪽의 "Labels" 열에 주목하세요. myuser는 다음 명령을 사용하여 공유 레이블이 있는 모든 리소스를 쿼리할 수 있습니다:
# Query all servers with a label
$ tsh ls env=example
커스터마이즈된 레이블은 teleport.yaml 구성 파일이나 서버 생성 시 정의할 수 있습니다.
이 기능은 고급 쿼리를 가능하게 하는 편리한 기능입니다. 예를 들어 IP 주소가 변경되더라도 관리자는 레이블이 변경되지 않으므로 해당 레이블로 현재 서버를 빠르게 찾을 수 있습니다.
레이블이 있는 모든 서버에서 명령 실행#
myuser는 또한 레이블을 공유하는 모든 서버에서 명령을 실행하여 반복 작업을 크게 단순화할 수 있습니다. 예를 들어, 다음 명령은 각 서버에서 ls 명령을 실행하고 터미널에 결과를 표시합니다:
# Run the ls command on all servers with a label
$ tsh ssh root@env=example ls
선택 사항: 서버 강화#
이전에 Teleport를 구성하고 설치하기 쉽도록 Linux 인스턴스에 포트 22를 열어 두었습니다. 일반적인 ssh 명령과 Teleport SSH를 자유롭게 비교해 보세요.
Teleport 서버를 강화하려면:
- Teleport 서버가 구성되고 실행 중이므로 프라이빗 Linux 인스턴스에서 포트
22를 닫습니다.
- 셀프 호스팅 배포의 경우, 선택적으로 Proxy Service 호스트에서 포트
22를 닫습니다.
tsh ssh를 사용하여 프라이빗 인스턴스에 완전히 연결할 수 있으며, 셀프 호스팅 배포의 경우 Proxy Service 호스트에도 연결할 수 있습니다.
결론#
이 가이드에서 설명한 내용을 정리합니다:
- SSH 서버를 설정하고 클러스터에 추가하는 방법.
tsh를 사용하여 클러스터에 연결하고 리소스를 관리 및 검사하는 방법.
리소스를 종료, 정리, 삭제하거나 추가적인 시작하기 연습에 활용해도 됩니다.
다음 단계#
- 이 가이드에서는 서버에 접근하기 위해 로컬 사용자를 생성하는 방법을 보여주었지만, Teleport 사용자가 Single Sign-On 공급자를 통해 인증하도록 설정할 수도 있습니다. 자세한 내용은 문서를 참조하세요.
- 참조 문서를 통해 Teleport
tsh에 대해 더 알아보세요.
- Teleport에서 사용하는 전체 포트 목록은 네트워킹 가이드를 참조하세요.
참고 자료#
- SSH 배스천 호스트 설정하기
- Teleport SSH 서버 발표
- 올바른 SSH 사용 방법
- OpenSSH와 Teleport SSH 중 어떤 것이 적합한지 고려해 보세요.
- 레이블
