SSH Agent Quick Fix
A short troubleshooting guide for resetting your SSH agent and reconnecting through a jump host.
Jan 2, 2026
The Problem
Your SSH connection fails even though the private key exists on your machine. This usually happens when the SSH agent has stale or incorrect keys loaded from a previous session.
Common symptoms:
Permission denied (publickey)errors- Agent offers the wrong key to the server
- ProxyJump connections hang or get rejected
The Fix
Three commands to reset and reconnect:
1. Clear all loaded keys
ssh-add -D
This removes every key from the running SSH agent. Your key files on disk are untouched.
2. Re-add the correct key
ssh-add ~/.ssh/your-key.pem
Verify it was loaded:
ssh-add -l
You should see your key's fingerprint in the output.
3. Reconnect through the jump host
ssh -A -J user@JUMP_PUBLIC_IP user@PRIVATE_IP
| Flag | Purpose |
|---|---|
-A | Forwards your SSH agent to the jump host |
-J user@JUMP_PUBLIC_IP | Routes through the jump host (bastion) |
user@PRIVATE_IP | Final destination server |
Security Note
Only use -A (agent forwarding) with jump hosts you control and trust. A compromised jump host could use your forwarded agent to access other servers.
Quick Reference
# Full reset-and-reconnect one-liner
ssh-add -D && ssh-add ~/.ssh/your-key.pem && ssh -A -J user@JUMP_PUBLIC_IP user@PRIVATE_IP