SSH BridgeSSH Bridge
<- Back to SSH Academy

DevOps

Terraform SSH

Use Terraform SSH provisioners carefully and prefer repeatable workflows.

Short answer

Terraform SSH connects SSH knowledge to automation and delivery workflows. Use it carefully because CI/CD systems often hold powerful credentials.

What you will learn

  • Provisioner limits
  • Bootstrap use cases
  • Safer alternatives

Why this matters

Terraform SSH matters because automation turns SSH from a personal login tool into a deployment and infrastructure control plane. Mistakes here can affect many systems quickly.

Connect build systems, deployment scripts, and automation tools to remote hosts.
Keep infrastructure automation predictable across environments.
Avoid embedding long-lived secrets directly inside scripts or pipeline logs.
Separate one-time bootstrap access from repeatable production workflows.

How it works

DevOps SSH usually appears in deployment scripts, configuration management, CI runners, container hosts, and emergency access. The credentials often have more reach than a normal developer session.

The safest pattern is to scope each credential to a narrow purpose. A deployment key should deploy, not administer the whole fleet. A CI runner should have limited host access and clear logs.

Prefer idempotent tools for long-term infrastructure state. Use SSH for access, bootstrap, diagnostics, and controlled execution rather than as a pile of hidden shell commands.

Practical example

The exact command or configuration depends on your operating system and security policy, but this pattern is a useful starting point for understanding the workflow.

connection {
  type = "ssh"
  user = "ubuntu"
  host = self.public_ip
}

Always test examples in a non-critical session first. SSH server settings can lock you out if authentication, firewall, DNS, or host key state is not understood.

Production checklist

Use scoped deploy users or machine users instead of personal admin keys.
Keep private keys in secret stores, never repositories.
Pin or verify host keys for automation targets.
Log deployment actions and keep rollback commands documented.

Common mistakes

  • Putting private keys directly in repositories, build logs, or shell history.
  • Giving CI/CD broad server access when one deployment user would be enough.
  • Using SSH provisioners for everything instead of idempotent infrastructure tooling.

Troubleshooting signals

CI succeeds once then fails

Look for ephemeral runner state: missing known_hosts, missing agent setup, changed file permissions, or secrets unavailable in forked builds.

Automation hangs

SSH may be waiting for a host key prompt, password prompt, sudo prompt, or interactive command. Make non-interactive assumptions explicit.

Deploy key has too much power

Review the remote user permissions and command scope. Automation credentials should be easy to rotate and narrow by default.

Security notes

  • Use scoped deploy keys or machine users instead of personal admin keys.
  • Avoid printing secrets, host keys, or private connection details in CI logs.
  • Rotate credentials after incidents, team changes, or runner compromise.

Use SSH Bridge when this becomes a team workflow

SSH Bridge helps DevOps teams centralize access patterns around hosts, projects, tunnels, and secure workflows instead of letting every pipeline and laptop invent its own SSH process.

Download SSH Bridge