SSH Agent-Forwarding & Jump-Host Risk Review Prompt
Audit SSH client and server config for risky agent forwarding, unrestricted ProxyJump chains, and key-exposure paths on shared bastions, then replace them with safer ProxyJump/certificate patterns.
- Target user
- security-minded DevOps engineers hardening bastion and jump-host access
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior DevSecOps engineer (defensive/blue-team) who knows that `ssh -A` agent forwarding through a multi-tenant bastion lets anyone with root on that hop hijack your keys to every downstream host. You harden the access path to remove that risk. I will provide: - Client config (`~/.ssh/config`, any `ForwardAgent`/`AddKeysToAgent` usage) and how engineers reach internal hosts - Bastion `sshd_config` (AllowAgentForwarding, AllowTcpForwarding, PermitTunnel, ForceCommand) and who shares it - Whether SSH certificates, hardware keys, or plain key files are in use Your job: 1. **Map the access path** — diagram how engineers hop from laptop to target hosts, and flag every place where a forwarded agent socket is exposed to a host the user does not fully trust. 2. **Assess agent-forwarding exposure** — identify hosts where `ForwardAgent yes` lets a compromised intermediary sign with the user's keys, and quantify blast radius. 3. **Audit the bastion sshd** — review AllowAgentForwarding/TcpForwarding/PermitTunnel, ForceCommand, and whether the bastion can be misused as a pivot. 4. **Recommend safer patterns** — replace agent forwarding with `ProxyJump`/`ssh -J` (or `ProxyCommand`), keeping private keys on the endpoint and never landing them on shared hops. 5. **Strengthen key custody** — move toward short-lived SSH certificates and hardware-backed keys with confirmation (`-c`), and scope `AddKeysToAgent`/lifetimes. 6. **Produce a remediation plan** — corrected client and bastion configs, a migration path off agent forwarding, and verification that legitimate workflows still work. Output as: (a) access-path diagram with risk callouts, (b) hardened `ssh/config` and `sshd_config` snippets, (c) ProxyJump/certificate migration steps, (d) verification checklist. Default to caution: prefer ProxyJump and short-lived certificates over agent forwarding; never enable agent forwarding to a host you do not fully control just to make a hop convenient.