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:06

I was getting same error during 'git push'. In client side I had two origin and master. I removed one, then it worked fine.

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

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.

查看更多
萌妹纸的霸气范
4楼-- · 2019-01-01 08:07

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.

查看更多
君临天下
5楼-- · 2019-01-01 08:07

I think i have the best answer for you, your git apps read your id_rsa.pub in root user directory

/home/root/.ssh/id_rsa.pub

That's why your key in /home/your_username/.ssh/id_rsa.pub can't be read by git. So you need to create the key in /home/root/.ssh/

$ sudo su
$ ssh-keygen
$ cd ~/.ssh
$ cat id_rsa.pub

Then copy the key in your github account. It's worked for me. You can try it.

查看更多
素衣白纱
6楼-- · 2019-01-01 08:08

I had the same issue recently. This might help if you need a fix immediately, but this needs to be done every time you re-start your system

From terminal, run : ssh-add ~/.ssh/id_rsa

Enter your system password and that should work.

查看更多
爱死公子算了
7楼-- · 2019-01-01 08:10

Use the URL for this page when adding GitHub as a remote. it wont cause any such error and push the code

查看更多
登录 后发表回答