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.
If you have already created an SSH key and are still getting the error it is because you need to give the user permissions to read and write to the folder you are cloning into. To do this,
sudo chmod 777 <your_folder_name_here>"
. Of course, this is after you have generated an SSH key and you are still getting this error. Hope this helps future users.Edit
To add on to this use admin in Windows if you're using the git bash
I was getting this error. Turns out I had just upgraded OSX to Sierra and my old key was no longer registered.
At first I thought it was "Upgrading to macOS Sierra will break your SSH keys and lock you out of your own servers"
But I had sidestepped that one. Turns out I just had to re-register my existing key:
ssh-add -K
And type the passphrase... done!
If you are using the GitHub for Mac UI, check preferences to make sure you're logged in.
This happened to me. For some reason my origin got messed up without my realizing it:
Check if your settings are still correct
the url needs to be something like ssh://git@github.com/YourDirectory/YourProject.git; if you don't see git@github.com, use
to set it right. Or you could use the github app to check and set the Primary Remote Repository url in the settings panel of your particular repository.
I know this problem. After add ssh key, add you ssh key to ssh agent too (from oficial docs https://help.github.com/articles/generating-ssh-keys/)
After it, all work fine, git can view proper key, before coudn't.
I would like to add some of my findings:
If you are using
GitBash
, then make sure the SSH key is stored in~/.ssh/id_rsa
.By Default
GitBash
searches for~/.ssh/id_rsa
as default path for SSH key.Even the file name
id_rsa
matters. If you save your SSH key in another filename or path, it will throw thePermission Denied(publickey)
error.