Debugging SSH
troubleshootingSSH failures are rarely mysterious once you ask the right tool. Four tools cover almost every case: verbose output (ssh -v) shows what the client tried and where it failed, config resolution (ssh -G) shows what configuration actually applied, agent inspection (ssh-add -l) shows which keys are loaded, and server-side logs show why the server said no.
Watch the connection
ssh -v user@server # Basic verbosity
ssh -vv user@server # More detail
ssh -vvv user@server # Maximum detail
Look for: which keys are being tried, the authentication method used, and where failures occur.
Check what config resolved
ssh -G hostname
Shows all resolved options, which config rules matched, and the final values used. Use case: debugging unexpected SSH behavior—this is how you find out SSH is using a different key than you think.
Inspect the agent
ssh-add -l
Shows all keys currently loaded in the agent. Add a key with ssh-add ~/.ssh/id_example (cache passphrase for session); clear everything with ssh-add -D.
Read the server's side (requires existing access)
sudo tail -20 /var/log/auth.log
# or on some systems:
sudo journalctl -u sshd -n 20
The server will log exactly why it rejected the key.