TCP 애플리케이션 접근
Teleport는 모든 TCP 기반 애플리케이션에 대한 접근을 제공할 수 있습니다. Teleport 관리자는 Teleport 애플리케이션 서비스가 TCP 애플리케이션을 프록시하도록 구성합니다. 다른 Teleport 보호 리소스와 마찬가지로, TCP 애플리케이션은 에이전트(Teleport 애플리케이션 서비스)와 동일한 네트워크에 있어야 하지만, 에이전트와 Teleport 보호 리소스는 Teleport 프록시 서비스와 별도의 네트워크에서 실행될 수 있습니다.
Teleport는 모든 TCP 기반 애플리케이션에 대한 접근을 제공할 수 있습니다. 이를 통해 사용자는 SMTP 서버나 Teleport 데이터베이스 서비스에서 아직 기본적으로 지원하지 않는 데이터베이스와 같이 Teleport가 기본적으로 지원하지 않는 애플리케이션에 연결할 수 있습니다.
작동 방식#
Teleport 관리자는 Teleport 애플리케이션 서비스가 TCP 애플리케이션을 프록시하도록 구성합니다. 최종 사용자는 상호 TLS를 사용하여 Teleport 프록시 서비스에 인증하는 로컬 프록시를 시작합니다. 프록시 서비스는 로컬 프록시에서 Teleport 애플리케이션 서비스로, 그리고 반대 방향으로 트래픽을 전달하며, 애플리케이션 서비스는 Teleport로 보호되는 TCP 애플리케이션으로/에서 트래픽을 프록시합니다.
다른 Teleport 보호 리소스와 마찬가지로, TCP 애플리케이션은 에이전트(Teleport 애플리케이션 서비스)와 동일한 네트워크에 있어야 하지만, 에이전트와 Teleport 보호 리소스는 Teleport 프록시 서비스와 별도의 네트워크에서 실행될 수 있습니다.
사전 요구 사항#
-
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.
- 연결할 TCP 애플리케이션. 이 가이드에서는 예시로 Docker에서 실행 중인 PostgreSQL을 사용합니다. 이미 보유한 TCP 기반 애플리케이션을 사용해도 됩니다.
- Teleport 애플리케이션 서비스를 실행할 호스트.
Teleport 클러스터가 teleport.example.com에서 접근 가능하다고 가정합니다. Teleport 프록시 서비스의 주소로 대체할 수 있습니다. (Teleport Cloud 고객의 경우 example.teleport.sh와 유사합니다.)
1/4단계. PostgreSQL 컨테이너 시작#
연결할 애플리케이션이 이미 있는 경우 이 단계를 건너뜁니다.
Docker 컨테이너에서 PostgreSQL 서버를 시작합니다:
$ docker run --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=<pass> -d postgres
2/4단계. Teleport 애플리케이션 서비스 시작#
Teleport 애플리케이션 서비스는 클러스터에 참여하기 위한 유효한 인증 토큰이 필요합니다.
토큰을 생성하려면 Auth Service 노드에서 다음 명령을 실행하세요:
$ tctl tokens add --type=app
다음으로 클러스터 애플리케이션에 연결할 수 있도록 access 역할을 가진 Teleport 사용자를 생성합니다:
$ tctl users add --roles=access alice
토큰을 생성하려면 Cloud 테넌트에 로그인하고 다음 명령을 실행하세요:
$ tsh login --proxy=mytenant.teleport.sh
$ tctl tokens add --type=app
생성된 토큰을 애플리케이션 서비스를 실행할 노드의 /tmp/token에 저장합니다.
이제 애플리케이션 서비스 노드에 Teleport를 설치합니다. Teleport 프록시와 프록시할 TCP 애플리케이션 모두에 접근할 수 있어야 합니다.
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
다음 내용으로 애플리케이션 서비스 구성 파일 /etc/teleport.yaml을 생성합니다:
version: v3
teleport:
auth_token: "/tmp/token"
proxy_server: teleport.example.com:3080
auth_service:
enabled: false
ssh_service:
enabled: false
proxy_service:
enabled: false
app_service:
enabled: true
apps:
- name: "tcp-app"
uri: tcp://localhost:5432
URI 스킴이 반드시 tcp://이어야 Teleport가 이를 TCP 애플리케이션으로 인식합니다.
Configure your Teleport instance to start automatically when the host boots up by creating a systemd service for it. The instructions depend on how you installed your Teleport instance.
You can check the status of your Teleport instance with systemctl status teleport
and view its logs with journalctl -fu teleport.
3/4단계. 앱 프록시 시작#
Teleport 클러스터에 로그인하고 사용 가능한 애플리케이션을 확인합니다:
$ tsh login --proxy=teleport.example.com
$ tsh apps ls
Application Description Type Public Address Labels
----------- ------------- ---- -------------------------------- -----------
tcp-app TCP tcp-app.teleport.example.com
TCP 애플리케이션이 TCP 타입으로 표시되어야 합니다.
이제 애플리케이션에 로그인합니다:
$ tsh apps login tcp-app
Logged into TCP app tcp-app. Start the local TCP proxy for it:
tsh proxy app tcp-app
Then connect to the application through this proxy.
다음으로 로컬 프록시를 시작합니다:
$ tsh proxy app tcp-app
Proxying connections to tcp-app on 127.0.0.1:55868
tsh proxy app 명령은 대상 애플리케이션에 대한 모든 연결을 프록시하는 리스너를 설정합니다.
4/4단계. 연결#
로컬 프록시가 실행 중이면 일반적으로 사용하는 애플리케이션 클라이언트를 사용하여 애플리케이션에 연결할 수 있습니다:
$ psql postgres://postgres@localhost:55868/postgres
다음 단계#
여러 포트에 대한 접근 구성#
기본적으로 애플리케이션 서비스는 애플리케이션 사양의 uri 필드로 연결을 프록시합니다. 그러나 Teleport는 TCP 애플리케이션의 여러 포트에 대한 접근을 활성화할 수 있습니다. 이 경우 애플리케이션 사양에는 uri 필드에 포트 번호가 없어야 하며, 포트 목록이 포함된 tcp_ports라는 새 필드가 필요합니다.
예를 들어, 위 단계에서 tcp-app을 가져와 8080 포트와 31276-32300 포트 범위에 대한 접근을 추가해 보겠습니다. 애플리케이션 서비스 정의는 다음과 같아야 합니다:
app_service:
enabled: true
apps:
- name: "tcp-app"
uri: tcp://localhost # URI에 포트 없음
tcp_ports:
- port: 5432 # PostgreSQL
- port: 8080 # HTTP 서버
- port: 31276
end_port: 32300 # 범위의 포함 끝
앱에 접근하려면 VNet을 시작하고 애플리케이션 클라이언트를 대상 포트로 지정하세요:
# HTTP 서버에 8080을 사용합니다.
$ curl -I http://tcp-app.teleport.example.com:8080
HTTP/1.1 200 OK
# postgres에 5432를 사용합니다.
$ psql postgres://postgres@tcp-app.teleport.example.com:5432/postgres
VNet 없이 tsh proxy app을 사용하고 리스닝 포트 뒤에 대상 포트를 지정합니다. 프록시에 대한 모든 연결은 해당 대상 포트로 라우팅됩니다.
# 12345를 리스닝 포트로 사용하고 8080을 대상 포트로 사용합니다.
$ tsh proxy app tcp-app --port 12345:8080
Proxying connections to tcp-app:8080 on 127.0.0.1:12345
# 랜덤 리스닝 포트와 5432를 대상 포트로 사용합니다.
$ tsh proxy app tcp-app --port 0:5432
Proxying connections to tcp-app:5432 on 127.0.0.1:65060
TCP 포트에 대한 RBAC는 없습니다. 애플리케이션에 접근할 수 있는 사용자는 사양에 있는 모든 포트에 연결할 수 있습니다. 접근 가능하도록 의도된 포트를 포함하는 광범위한 포트 범위를 정의하는 대신 필요한 포트만 지정하는 것을 강력히 권장합니다.
여러 포트 지원은 Teleport v17.1 이상에서 사용 가능합니다. 여러 포트를 지원하지 않는 Teleport 클라이언트에서의 연결은 애플리케이션 사양의 첫 번째 포트로 라우팅됩니다. 여러 포트를 지원하지 않는 애플리케이션 서비스는 Auth Service에서 동적 등록을 통해 수신한 경우 멀티 포트 애플리케이션에 대한 트래픽을 처리할 수 없습니다.
추가 읽기#
- 애플리케이션의 접근 제어에 대해 알아보기
- VNet으로 TCP 앱에 연결하고 사용자 지정
public_addr에 대한 VNet 구성하는 방법 알아보기
