GitHub Error Message - Permission denied (publickey)

GitHub isn't able to authenticate you. So, either you aren't setup with an SSH key, because you haven't set one up on your machine, or your key isn't associated with your GitHub account.

You can also use the HTTPS URL instead of the SSH/git URL to avoid having to deal with SSH keys. This is GitHub's recommended method.

Further, GitHub has a help page specifically for that error message, and explains in more detail everything you could check.


I know about this problem. After add ssh key, add you ssh key to ssh agent too (from official docs)

ssh-agent -s
ssh-add ~/.ssh/id_rsa

After it all work fine, git can view proper key, before couldn't.


Did you create a config file in your ~/.ssh directory? It should have contents like these:

Host github.com 
 IdentityFile ~/.ssh/github_rsa

Assuming that you created an ssh key named github_rsa

and uploaded it to GitHub...

NOTE: You must follow this way of explicit configuration if you have more than 1 key (2 and more) in your ~/.ssh/ directory. If you don't specify key this way, then first key in order is taken and used for github authentication, so it depends on the key file name then.

Tags:

Git

Github