Centralized Access Control with Teleport: A Guide to SSH, Kubernetes, and Database Security

Security tutorial - IT technology blog
Security tutorial - IT technology blog

Managing Infrastructure Without the Key-Management Nightmare

Managing SSH keys for five servers is easy. Managing them for fifty—while juggling Kubernetes clusters and production databases—is where the wheels fall off. During my first month as a sysadmin, I spent nearly 20 hours auditing authorized_keys files just to remove people who had left the company months prior. It wasn’t just tedious; it was a glaring security vulnerability.

Teleport fixes this by replacing permanent keys with short-lived certificates. Think of it as a unified access plane. It acts as a secure front door for your entire stack, requiring Multi-Factor Authentication (MFA) for every session and providing a crystal-clear audit trail of who did what, and when.

Quick Start: Get Teleport Up and Running in 5 Minutes

We’ll start by installing Teleport on a single Linux node. This instance will handle everything: the Auth Service (the CA), the Proxy (the gateway), and an SSH Node (the target).

1. Install the Teleport Binary

Teleport supports most modern Linux distros. If you’re on Ubuntu or Debian, use these commands to pull from the official repository:

sudo curl https://apt.releases.teleport.dev/gpg \
  -o /usr/share/keyrings/teleport-archive-keyring.asc

source /etc/os-release
echo "deb [signed-by=/usr/share/keyrings/teleport-archive-keyring.asc] \
  https://apt.releases.teleport.dev/${ID?} ${VERSION_CODENAME?} stable/v15" \
  | sudo tee /etc/apt/sources.list.d/teleport.list > /dev/null

sudo apt update
sudo apt install teleport

2. Generate the Configuration

You need a valid configuration file to define how Teleport behaves. If you have a domain name pointing to your server, you can automate SSL setup with Let’s Encrypt.

# Replace teleport.example.com with your domain or public IP
sudo teleport configure --acme [email protected] --cluster-name=teleport.example.com > /etc/teleport.yaml

3. Fire Up the Service

Now, enable the daemon so it automatically restarts after a reboot.

sudo systemctl enable teleport
sudo systemctl start teleport

4. Create Your Admin User

Finally, we need to create the first account. This command generates a one-time registration link that expires in one hour.

sudo tctl users add admin --roles=editor,access --logins=root,ubuntu,ec2-user

Open that link in your browser to set up your MFA—I recommend a YubiKey or Google Authenticator. For the master password, I use the browser-based generator at toolcraft.app/en/tools/security/password-generator. It’s fast, runs locally in your browser, and ensures you aren’t starting your setup with a weak credential.

The Architecture Shift: Certificates Over Keys

Teleport isn’t just an SSH wrapper; it’s a complete rethink of how we grant access. In a traditional setup, if a laptop is stolen, its private keys stay active until you manually hunt them down and revoke them. That is a recipe for disaster.

How Short-Lived Certificates Work

With Teleport, you run tsh login and authenticate with MFA. The Auth Service then hands you a certificate that expires in, say, 8 hours. When you connect to a server, the node validates that certificate against its trusted CA. Once those 8 hours are up, the certificate is useless. No cleanup, no orphaned keys, and no manual revoking required.

Three Parts of the Whole

  • Auth Service: The brain. It manages the Certificate Authority (CA) and enforces your access policies.
  • Proxy Service: The gatekeeper. It handles all incoming traffic. Because the Proxy tunnels sessions to internal nodes, your servers don’t need to be exposed to the public internet.
  • Node Service: The agent. It runs on your targets (servers, K8s, or DBs) and maintains a secure outbound connection to the Proxy.

Protocol Awareness

Teleport actually understands the traffic passing through it. For SSH, it records terminal output like a movie. For Kubernetes, it logs kubectl commands. For Databases, it logs the raw SQL queries. This is deep visibility that standard SSH tunnels simply can’t provide.

Protecting Your Databases Without Shared Credentials

Database Access is one of Teleport’s best features. You can give a developer access to a production PostgreSQL instance without ever handing over the database username or password. Everything is handled via certificates.

1. Add the Database to Teleport

Update your teleport.yaml on the server where your database resides (or a gateway node):

db_service:
  enabled: "yes"
  databases:
    - name: "prod-db"
      description: "Primary PostgreSQL Production"
      protocol: "postgres"
      uri: "localhost:5432"

Restart the service to apply the change. You’ll then configure the database to trust Teleport’s CA for authentication.

2. Accessing the DB via CLI

From your local terminal, the workflow is seamless:

tsh login --proxy=teleport.example.com
tsh db login prod-db

# Connect using your standard local tools
tsh db connect prod-db

Teleport spins up a local proxy, handles the certs in the background, and lets you use psql as you normally would. Meanwhile, every query you run is being logged for compliance.

Pro-Tips for Production

After running Teleport for a while, these three habits will save you a lot of grief.

Watch the Replays: The Web UI isn’t just for show. If a config file breaks at 3 AM, you can watch the session recording of the last person who logged in. It’s the fastest way to see exactly what went wrong without guessing.

Organize with Labels: Don’t just list nodes by hostname. Use labels like env: production or team: devops. This allows you to create smart RBAC rules, like “Backend devs can only access nodes where env is not production.”

Stay on the Update Path: Teleport moves fast. They ship major security and feature updates every few months. I usually stay one minor version behind the bleeding edge (e.g., using v15.1 when v15.2 drops) to ensure stability while staying patched.

Switching to Teleport transforms your security from “trust the network” to “trust the identity.” It takes a few more minutes to configure than a basic SSH key, but the peace of mind—knowing exactly who is touching your infrastructure—is worth the effort.

Share: