SSH Agent error after restarting computer
August 2022
After restarting my computer (Macbook/OS X), I often face problems in connecting with my AWS EC2 instances via Jumphost (also called as Bastion host).
Error
The agent has no identities
Fix
ssh-add -K ~/.ssh/id_rsa
ssh-add -A
On latest version of OS X, you can add UseKeychain yes
to your ~/.ssh/config
Host *
UseKeychain yes
Explanation
SSH Agent holds decrypted keys in memory and doesn’t write to disk. Hence, the keys must be unlocked after each restart. On OS X, ssh-add has a special flag related to Keychain. While this flag (-K) is a bit hard to find, however it works on most of the OS X versions.