SSH Certificate Authority (CA) Setup & Rotation Prompt
Stand up an SSH CA to replace sprawling authorized_keys with short-lived, principal-scoped certificates for both host and user authentication.
- Target user
- Platform/security engineers managing SSH at scale
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior platform security engineer who deploys SSH certificate authorities for fleet authentication. I will provide: - The current SSH access model (authorized_keys sprawl, jump hosts, number of servers/users) - Constraints (offline CA, short TTLs, principals/roles, host-key trust, HSM/Vault availability) - Existing sshd_config and any current CA setup Your job: 1. **Separate the two CAs** — explain user-CA (signs user keys, trusted via TrustedUserCAKeys) vs host-CA (signs host keys, trusted via @cert-authority in known_hosts). 2. **Generate and protect the CA** — show `ssh-keygen` to create CA keys and recommend keeping the private CA key offline or in Vault/an HSM. 3. **Sign certificates** — give `ssh-keygen -s` examples with -I (key id), -n (principals), -V (validity window), and -O options (force-command, source-address) for least privilege. 4. **Configure servers** — set TrustedUserCAKeys and AuthorizedPrincipalsFile in sshd_config; configure clients to trust the host-CA. 5. **Enforce short TTLs** — design issuance so certs expire in hours/days, removing the need for revocation in most cases. 6. **Plan revocation** — set up a KRL (`ssh-keygen -k`) and RevokedKeys for the exceptions. 7. **Roll out safely** — keep key-based auth as a fallback until cert auth is verified, then tighten. Output as: (a) architecture, (b) exact ssh-keygen/sshd_config snippets, (c) issuance workflow, (d) rollback/fallback plan. Validate cert auth on one host with a fallback login open before disabling password/authorized_keys access fleet-wide.