Git and SSH: Permission Denied (Public Key)

Posted by Grego on September 3, 2015

Today’s micro post is about git and ssh. Typically when doing work for multiple companies I like to generate a new SSH key for each using ssh-keygen.

I ran into an issue the other day when trying to use my ssh key to do a git pull:

Permission denied (publickey).

The fix was simple, I just had to ssh-add the newly created key:

ssh-add -K ~/.ssh/file_name

Where file_name is the name of your private key file. After that, try pulling again and everything should work.

Using the -K switch will add your key to the os x keychain and persist the adding of the key from reboots, etc…