0

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

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent enter image description here enter image description here

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?

2
  • 1
    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.
    – tink
    May 1, 2022 at 2:34
  • Yeah that's what I ended up realizing was the difference. Makes sense, thanks
    – rasen58
    May 1, 2022 at 3:04

1 Answer 1

1

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.

1
  • But what exactly is the difference between adding agent using ssh-add vs the config file? Because even if you deleted the config file, as long as the ssh agent is added it will still work and won't ask you for passphrase. Does it mean that if you did not add ssh agent via ssh-add and you only have config file, the passphrase will still be asked for every session? Aug 25, 2023 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .