SSH Authentication — Overview
The model: the container starts with an empty ssh-agent on a fixed socket
(/tmp/ansible-ssh-agent.sock). A playbook, run once, fetches the private key from wherever it's
stored and pipes it into that agent. Every terminal already has SSH_AUTH_SOCK pointed at the
socket, so the key becomes usable everywhere the instant it's loaded — including terminals opened
before the playbook ran.
This page is a quick-reference for setting up a production / customer deployment. For the full walkthrough, deeper detail, or the dev-environment equivalent, follow the links below.
Quick setup
- Store the key in the customer's own secret
store — AWS Secrets Manager, Azure Key Vault, or (no cloud secrets manager available) an
ansible-vault-encrypted file in
extra_vars/. - Grant the container's identity read access to that secret — the task role / instance profile (AWS) or the managed identity (Azure).
- Confirm
startup.shstarts the empty agent on container boot. Already wired for Coder workspaces; for a non-Coder container this is the one piece that needs adding. - Run the matching playbook once per container start (see Choosing a playbook if unsure which):
ansible-playbook playbooks/load-ssh-key.yml— cloud secret store, cloud auto-detectedansible-playbook playbooks/load-ssh-key-vault.yml -e @extra_vars/ssh_key.yml— ansible-vault route- Verify:
Choosing where the key lives
| Situation | Store | Playbook |
|---|---|---|
| AWS, with a task role / instance profile | AWS Secrets Manager | load-ssh-key.yml |
| Azure, with a managed identity | Azure Key Vault | load-ssh-key.yml |
| No cloud secrets manager (air-gapped / on-prem) | Ansible Vault | load-ssh-key-vault.yml |
Where to go next
- Production (Customers) — the full walkthrough: exact commands for
creating the secret and granting access in each cloud, the
startup.shsnippet, security notes. - Development Environment — how Sapphire's own Coder workspaces
do this (
coder_scriptinstead of a one-time playbook), useful for comparison. - Secret Management — the vault password itself, and the broader vault/env-var convention used across roles.