git push origin master 给出错误权限被拒绝(github)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7333734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:48:23  来源:igfitidea点击:

git push origin master gives error permission denied (github)

gitsshgithubkey

提问by Michael Durrant

ERROR: Permission to durrantm/linker.git deniedto kevinzen. fatal: The remote end hung up unexpectedly

错误:对 kevinzen拒绝durrantm/linker.git 的权限。致命:远端意外挂断

I've tried a lot of things to change/set my identity and get rid of that 'kevinzen'

我尝试了很多方法来改变/设置我的身份并摆脱那个“kevinzen”

Update - final resolution was that I had added my public key... but... I had missed a few characters so it was invalid. Pasting in the correct key on github fixed it

更新 - 最终解决方案是我添加了我的公钥......但是......我错过了几个字符,所以它是无效的。在github上粘贴正确的密钥修复它

I have ~/.ssh/with files

我有~/.ssh/文件

  • config
  • id_dsa
  • id_dsa.pub
  • id_kb_rsa
  • id_kb_rsa.pub
  • id_rsa
  • id_rsa.pub
  • known_hosts
  • config
  • id_dsa
  • id_dsa.pub
  • id_kb_rsa
  • id_kb_rsa.pub
  • id_rsa
  • id_rsa.pub
  • known_hosts

I have done

我已经做好了

git config --global user.name
git config --global user.email
git remote add origin [email protected]:durrantm/linker.git

I have added my local ssh key with my info (not kevinz) for this machine to github ssh keys.

我已经将我的本地 ssh 密钥和我的信息(不是 kevinz)添加到了这台机器的 github ssh 密钥中。

I also tried: ssh [email protected]. The authenticity of host 'github.com. (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com.' (RSA) to the list of known hosts. PTY allocation request failed on channel 0

我也试过: ssh [email protected]. The authenticity of host 'github.com. (207.97.227.239)' can't be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com.' (RSA) to the list of known hosts. PTY allocation request failed on channel 0

wasn't sure about the PTY error. Still stuck.

不确定 PTY 错误。还是卡住了。

回答by sanmai

Did you install your key at GitHub? Have you read help section there?

您是否在 GitHub 上安装了您的密钥?你读过那里的帮助部分吗?

You can list your own keys as saved at GitHubby:

您可以通过以下方式列出保存在 GitHub 上自己的密钥

curl https://github.com/<username>.keys

Have you checked that one of the keys is a match to one of your keys? Compare:

您是否检查过其中一个键是否与您的其中一个键匹配?相比:

cat ~/.ssh/id_*.pub

回答by Adam Wilson

I had the same problem, my solution was simple. I already have my keys setup and everything and kept trying to run:

我有同样的问题,我的解决方案很简单。我已经设置好我的密钥和所有东西并继续尝试运行:

git config --global user.name IceMupppet

After looking through my ~/.ssh/ I noticed that running:

在查看我的 ~/.ssh/ 后,我注意到正在运行:

ssh-add -l

I saw that to simply use the right git account I just added the right file:

我看到只是使用正确的 git 帐户我刚刚添加了正确的文件:

ssh-add ~/.ssh/id_IceMupppet_rsa

... then a git push origin masterworked fine. I have an alias on my ssh config to use different keys for my work and personal, but still had to do this step for some reason.

...然后git push origin master工作正常。我的 ssh 配置中有一个别名,可以为我的工作和个人使用不同的密钥,但由于某种原因仍然必须执行此步骤。