Reputation: 453
Somewhat of a noob question but everyday at work when I open git bash I have to start the ssh-agent daemon and I have to add my ssh-private key to the user-agent so that Github knows who I am.
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
If I dont do this I cannot pull/push to github.
It gets a little annoying to have to do this everyday, is there a way to add it permanently?
Upvotes: 11
Views: 14421
Reputation: 131
Another way that it solved myself the same problem, was moving the private key, e.g id_rsa
, to the default ssh key location, ~/.ssh
.
cp /your/key/location/id_rsa ~/.ssh
It seems that for some reason, when you add an identity from a different location with the -i
option of the ssh-add
command, it doesn't add it permanently.
Upvotes: 1
Reputation: 530852
Instead of using ssh-agent
, put the following in your .ssh/config
file:
Host github.com
IdentityFile ~/.ssh/id_rsa
An agent is primarily useful either to avoid creating a large number of configurations in .ssh/config
(as any connection will attempt to use a key found in the agent), or for allowing remote SSH sessions to reach back to your local machine for necessary keys.
Upvotes: 14