I noticed that the Github instructions for adding an ssh key to your account say that you need to add the key to both your ~/.ssh/config file AND to the ssh agent with ssh-add
But, I just noticed however that if I clear the keys from the ssh agent with ssh-add -D, then I'm still able to push and pull from my github repos just fine.
I think this makes sense because in my ~/.ssh/config file, I specify that for Host * (all hosts), the exact IdentityFile to use, so it will use that one automatically.
So, my question is - why even add the key to the ssh-agent directly at all? Is there a case in which my way of only added to the ~/.ssh/config file won't work?
21 Answer
I hope you set a passphrase on that identity-file?
If you didn't you probably won't notice a difference; if you did, adding it to the agent will allow you to enter the passphrase ONCE for the life-time of the running agent (or till you clear the identity).
W/o the agent I'd expect you to be prompted for every connection attempt.