GitHub Error Message - Permission denied (publicke

2019-01-01 07:47发布

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.

标签: git github
30条回答
低头抚发
2楼-- · 2019-01-01 08:31

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

查看更多
弹指情弦暗扣
3楼-- · 2019-01-01 08:32

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!

查看更多
听够珍惜
4楼-- · 2019-01-01 08:32

If you are using the GitHub for Mac UI, check preferences to make sure you're logged in.

查看更多
柔情千种
5楼-- · 2019-01-01 08:33

This happened to me. For some reason my origin got messed up without my realizing it:

Check if your settings are still correct

git remote -v

the url needs to be something like ssh://git@github.com/YourDirectory/YourProject.git; if you don't see git@github.com, use

git remote set-url origin git://github.com/YourDirectory/YourProject.git

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.

查看更多
人间绝色
6楼-- · 2019-01-01 08:33

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/)

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

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

查看更多
冷夜・残月
7楼-- · 2019-01-01 08:33

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_rsaas 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 the Permission Denied(publickey)error.

查看更多
登录 后发表回答