[Teleport Docker Compose] Run Teleport with Docker Compose
Run Teleport with Docker Compose
Teleport is a Certificate Authority and an Access Plane for your infrastructure. With Teleport you can:
-
Set up Single Sign-On and have one place to access your SSH servers, Kubernetes, Databases, Desktops, and Web Apps.
-
Use your favorite programming language to define access policies to your infrastructure.
-
Share and record interactive sessions across all environments.
This article will help you understand how Teleport works using Docker Compose. It will also show you how to use Teleport with OpenSSH, Ansible, and Teleport’s native client, tsh.
Prerequisites
-
Teleport v9.0.0 Open Source or Enterprise.
-
Docker v20.10.7 or later and docker-compose v1.25.0 or later.
1 | docker-compose version |
Configuration
Teleport uses the YAML file format for configuration. A full configuration reference file is shown below, this provides comments and all available options for teleport.yaml
By default, it is stored in /etc/teleport.yaml
.
1 | docker run --hostname localhost --rm \ |
It will generate teleport.yaml
file in ./runtime/teleport/etc/teleport
directory for container later.
1 | # /etc/teleport.yaml |
See Teleport Configuration Reference | Teleport Docs - https://goteleport.com/docs/setup/reference/config/ to learn more.
Run with Docker Compose
First, create docker-compose.yaml
file.
1 | # docker-compose.yaml |
Then, run docker-compose up
1 | docker-compose up |
Usages
Explore CLI
Let’s jump into container with setup clients and explore Teleport:
From your local terminal
1 | docker exec -ti teleport /bin/bash |
We will run all future commands from the teleport container.
You can see Teleport’s nodes registered in the cluster using tsh ls command:
1 | From teleport container |
Explore web UI
Create a Teleport user called cloudolife which is allowed to log in as either operating system user root or ubuntu.
1 | From term container |
Teleport will output a URL that you must open to complete the user sign-up process:
User “cloudolife” has been created but requires a password. Share this URL with the user to complete user setup, link is valid for 1h:
`https://localhost:3080/web/invite/your-token-here
NOTE: Make sure proxy.teleport:443
points at a Teleport proxy which users can access.
Port 443
on the Teleport container is published to the local host, so you can access the invitation page at https://localhost/web/invite/your-token-here
.
INSECURE CERTIFICATE ERROR
If you encounter an “Insecure Certificate Error” (or equivalent warning) that prevents the Teleport Web UI from opening, you can perform one of the following actions depending on your browser:
-
In Safari’s “This Connection Is Not Private” page, click “Show Details,” then click “visit this website.”
-
In Firefox, click “Advanced” from the warning page, then click “Accept the Risk and Continue.”
-
In Chrome’s warning page, type
thisisunsafe
to ignore certificate validation for the Teleport Web UI.
Explore tsh CLI
Use tsh ssh
to login and run tctl
within Telepor.
1 | tsh --proxy=localhost login --user=cloudolife --insecure |
Remember to ignore x509: certificate signed by unknown authority
error with --insecure
option.
List nodes within Teleport.
1 | tsh ls |
Run tsh ssh
to login localhost
host within Teleport.
1 | tsh ssh root@localhost |
See Using TSH | Teleport Docs - https://goteleport.com/docs/server-access/guides/tsh/, Teleport CLI Reference | Teleport Docs - https://goteleport.com/docs/setup/reference/cli/#tsh to learn more.
Create another Teleport user called col which is allowed to log in as either operating system user root or ubuntu.
1 | From root@localhost within Teleport |
Add node into Teleport
It will generate an invite token to add node.
1 | tctl nodes add |
Run teleport start
to register a host into Teleport as a node.
1 | On your host |
See Server Access Getting Started Guide | Teleport Docs - https://goteleport.com/docs/server-access/getting-started/ to learn more.
Check nodes.
1 | tctl nodes ls |
Run tsh ssh
to login your host through Teleport
1 | tsh ssh <Your User Name>@<Your Host>.local |
See Teleport CLI Reference | Teleport Docs - https://goteleport.com/docs/setup/reference/cli/#tctl to learn more.
Stop Teleport
You can stop the Teleport using:
1 | docker-compose down |
FAQs
ERROR: Get “https://localhost:3080/webapi/ping”: x509: certificate signed by unknown authority
1 | tsh --proxy=localhost login --user=blogbin |
Remember to ignore x509: certificate signed by unknown authority
error with --insecure
option.
1 | tsh --proxy=localhost login --user=cloudolife --insecure |
References
[3] Using TSH | Teleport Docs - https://goteleport.com/docs/server-access/guides/tsh/
[4] Teleport CLI Reference | Teleport Docs - https://goteleport.com/docs/setup/reference/cli/#tsh
[5] Teleport CLI Reference | Teleport Docs - https://goteleport.com/docs/setup/reference/cli/#tctl
[7] Teleport: Easiest, most secure way to access infrastructure | Teleport - https://goteleport.com/
[8] Overview of Docker Compose | Docker Documentation - https://docs.docker.com/compose/