The best answers to the question “GitHub Error Message – Permission denied (publickey)” in the category Dev.
Anybody seen this error and know what to do?
I’m using the terminal, I’m in the root, the GitHub repository exists and I don’t know what to do now.
> git push -u origin master Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
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.
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.
You need to generate an SSH key (if you don’t have one) and associate the public key with your Github account. See Github’s own documentation.
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.