Installing Privileged Access for SSH

Deploy the Gateway and configure SSH access using the Twingate Terraform provider.

The recommended way to install Privileged Access for SSH is with the Twingate Terraform provider, which publishes complete, runnable examples. Each guide includes the full Terraform configuration, startup scripts, and step-by-step deployment instructions for a specific cloud.

Prerequisites

What the Terraform guides set up

Each guide creates the same pieces, in this order:

  • Two certificate authorities. An X.509 CA secures the TLS connection between the Twingate Client and the Gateway. An SSH CA signs the short-lived certificates the Gateway uses to sign in to target servers.
  • Twingate objects. A Remote Network, both CAs registered with Twingate (twingate_x509_certificate_authority, twingate_ssh_certificate_authority), a twingate_gateway, and a Connector with its tokens.
  • An SSH Resource. A twingate_ssh_resource bound to the Gateway, with access granted to a Group.
  • The Gateway. A VM running the Twingate Gateway with a YAML configuration that points to its TLS certificate, the SSH CA key, and the account it signs in as (ssh.gateway.username).
  • The target SSH server. sshd configured to trust the SSH CA (TrustedUserCAKeys), with a Linux account that matches ssh.gateway.username.

Terraform quick-start guides

These guides use a local SSH CA for simplicity, where the Gateway holds the CA private key and signs certificates directly. This is a good way to try out SSH access through the Gateway.

Manual installation without Terraform

To run the Gateway as a Docker container and register it with the Twingate GraphQL API instead of Terraform, follow the Gateway SSH installation guide. It covers generating both CAs, creating the Gateway and SSH Resource, writing the Gateway configuration, and configuring each SSH server to trust the CA.

Vault as SSH CA

For production deployments, the Gateway can use HashiCorp Vault’s SSH secrets engine to sign certificates instead of a local CA. See the Vault integration guide for setup instructions.

Sign target server host keys

By default, the Gateway trusts each target server’s host key on first use (TOFU). To remove TOFU, sign each server’s host key with the SSH CA so the Gateway verifies it against the CA on every connection.

  • On each target server, sign the host key with the SSH CA private key:

    sudo ssh-keygen -s ssh_ca -I <hostname> -h \
    -n <hostname>,<address> -V +52w \
    /etc/ssh/ssh_host_ed25519_key.pub

    This writes /etc/ssh/ssh_host_ed25519_key-cert.pub. The -V +52w option makes the certificate valid for 52 weeks, so re-sign before it expires.

  • Add the host key and certificate to the sshd configuration, for example in /etc/ssh/sshd_config.d/twingate.conf:

    HostKey /etc/ssh/ssh_host_ed25519_key
    HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
    TrustedUserCAKeys /etc/ssh/twingate_ca.pub
  • Reload sshd.

Next steps

After the Gateway is running and your SSH Resources are accessible, see Remote Development with VS Code to set up VS Code Remote SSH.

Last updated