15
5
I recently reinstalled my laptop and found that 'git clone' wasn't working. I was consistently receiving Permission denied (publickey).
errors.
The fix is documented on GitHub's SSH issues page: use ssh-add
to tell SSH about the key I want to use to authenticate on GitHub.
My question is: under the hood, what does ssh-add
actually do?
I've been meaning to expand my understanding of SSH for a while, & this seems like a good excuse to start :-)
I'll be honest, this confused me for a while. I thought the ssh client always used the key in your
~/.ssh
directory. Do some distros do the equivalent ofssh-add
automatically? Maybe that's why I was confused? – blong – 2015-04-11T01:21:38.9204
ssh
does use the key in the~/.ssh
directory, but if the key is protected by a passphrase, this passphrase must be entered at some point. If you usessh-agent
andssh-add
, you type this passphrase once. Otherwise you must type the passphrase each time you usessh
. Note that if the key is not password protected, you can usessh
without being asked for a passphrase. – Peter John Acklam – 2015-07-10T09:39:05.440There can be multiple ssh keys in
– Frank Nocke – 2018-04-11T11:01:07.520~/.ssh
and this might be the more useful thing to have, see on SO and bitbucket docs