热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Git著名的“错误:拒绝用户权限”-Git'sfamous“ERROR:Permissionto.gitdeniedtouser”

Ihavetriedgooglingandreadthroughhttp:help.github.comtroubleshooting-sshandvarious,vari

I have tried googling and read through http://help.github.com/troubleshooting-ssh/ and various, various guides. I am unable to git push -u origin master or git push origin master ( the same command ).

我尝试过谷歌搜索和阅读http://help.github.com/troubleshooting-ssh/以及各种各样的指南。我不能使用git推-u源母版或git推源母版(相同的命令)。

I've had my git account for at least 2 or so years. I've successfully been able to create repos and push -u origin master fine on my laptop but on this desktop I'm having issues.

我的git账户至少有两年左右的历史了。我已经成功地在我的笔记本电脑上创建了repos和push -u master master,但是在这个桌面我有问题。

Here's what I tried:

这就是我试着:

1. I have setup my git user name

1。我设置了git用户名

2. I have setup my git user email

2。我已经设置了git用户邮件

3. I have uploaded the contents of my /home/meder/.ssh/id_rsa.pub to github's account page. I have verified I did not paste any whitespace

3所示。我已经上传了我的/home/meder/.ssh/id_rsa的内容。到github的账户页面。我已经验证过我没有粘贴任何空格

4. I have created a ~/.ssh/config with these contents:

4所示。我创造了一个~。ssh / config与这些内容:

  Host github.com
  User git
  Hostname github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_rsa

I have chmodded the .ssh to 700, id_rsa 600

我修改了。ssh到700,id_rsa 600

5. I have added the proper remote origin without making typos : git remote add origin git@github.com:medero/cho.git

5。我添加了正确的远程起源,但没有输入错误:git remote add origin git@github.com:medero/cho.git

6. To confirm #5, here is my .git/config. The directory is correct and not another directory:

6。要确认#5,这是我的.git/config。目录是正确的,而不是另一个目录:

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:medero/cho.git

7. ssh git@github.com -v gives me a successful Authentication

7所示。ssh git@github.com -v给了我一个成功的身份验证

8. One weird thing is, the username which it greets me with has t appended to it. My github username is medero, not medert.

8。一个奇怪的事情是,它向我打招呼的用户名后面加了t。我的github用户名是medero,而不是medert。

Hi mederot! You've successfully authenticated, but GitHub does not provide shell access.

嗨mederot !您已经成功地进行了身份验证,但是GitHub不提供shell访问。

9. I am not behind a proxy or firewall

9。我不在代理或防火墙后面

10. The key is offered, heres the output from -v:

10。钥匙提供了,以下是-v的输出:

debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/meder/.ssh/known_hosts:58
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/meder/.ssh/id_rsa
debug1: Remote: Forced command: gerve mederot
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: { some stuff, dont know if i should share it

debug1: Remote: Forced command: gerve mederot
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Authentication succeeded (publickey).

11. Here are the commands I used

11。下面是我使用的命令

mkdir cho
git init
touch README
git add README
git commit -m 'test'
git remote add origin git@github.com:medero/cho.git
git push -u origin master

12. I don't want to create a new SSH key.

12。我不想创建一个新的SSH密钥。

13. If I git clone using ssh and make an edit, commit, and git push, I get the same exact thing.

13。如果我使用ssh克隆并进行编辑、提交和git推送,我将得到相同的结果。

14. Here's the actual error:

14。这是实际的错误:

$ git push
ERROR: Permission to medero/cho.git denied to mederot.
fatal: The remote end hung up unexpectedly

15. I have setup my github username and github token:

15。我设置了我的github用户名和github令牌:

$ git config --global github.user medero $ git config --global github.token 0123456789yourf0123456789tokenSets the GitHub token for all git instances on the system

$ git配置——全局github。用户medero $ git配置——全局github。令牌0123456789yourf0123456789tokenset GitHub令牌用于系统中的所有git实例

16. I have confirmed my github username is NOT mederot and my github token IS CORRECT per my account page ( validated first 2 chars and last 2 chars ).

16。我已经确认我的github用户名不是mederot,我的github令牌在我的账户页面上是正确的(验证了前两个chars和后两个chars)。

17. To confirm #16, ~/.gitconfig contains

17所示。~ /确认# 16日。gitconfig包含

[github]
    token = mytoken...
    user = medero

18. I did ssh-key add ~/.ssh/id_rsa if that's even necessary...

18岁。我做了ssh-key add ~/。ssh/id_rsa如果有必要……



THEORIES:

理论:

I suspect there's something fishy because when I get ssh authenticated, the user greeting is mederot and not medero, which is my acct. Could something in my github account possibly be incorrectly cached?

我怀疑有什么可疑的东西,因为当我通过ssh认证时,用户的问候是mederot而不是medero,这是我的acct。我的github帐户上的某些东西可能被错误地缓存了吗?

I also suspect some local ssh caching weirdness because if i mv ~/.ssh/id_rsa KAKA and mv ~/.ssh/id_rsa.pub POOPOO, and do ssh git@github.com -v, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!

我还怀疑本地ssh缓存有些奇怪,因为如果我mv ~/。ssh/id_rsa KAKA和mv ~/.ssh/id_rsa。pub POOPOO,还有ssh git@github.com -v,它仍然对我进行认证,并说它服务于我的/home/meder/。当我重命名它的时候?!它必须被缓存?!

10 个解决方案

#1


32  

In step 18, I assume you mean ssh-add ~/.ssh/id_rsa? If so, that explains this:

在第18步中,我假设您是指ssh-add ~/.ssh/id_rsa?如果是这样,这就解释了这一点:

I also suspect some local ssh caching weirdness because if i mv ~/.ssh/id_rsa KAKA and mv ~/.ssh/id_rsa.pub POOPOO, and do ssh git@github.com -v, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!

我还怀疑本地ssh缓存有些奇怪,因为如果我mv ~/。ssh/id_rsa KAKA和mv ~/.ssh/id_rsa。pub POOPOO,还有ssh git@github.com -v,它仍然对我进行认证,并说它服务于我的/home/meder/。当我重命名它的时候?!它必须被缓存?!

... since the ssh-agent is caching your key.

…因为ssh-agent正在缓存您的密钥。

If you look on GitHub, there is a mederot account. Are you sure that this is nothing to do with you? GitHub shouldn't allow the same SSH public key to be added to two accounts, since when you are using the git@github.com:... URLs it's identifying the user based on the SSH key. (That this shouldn't be allowed is confirmed here.)

如果你看看GitHub,你会发现一个mederot账号。你确定这与你无关吗?GitHub不应该允许将相同的SSH公钥添加到两个帐户中,因为当您使用git@github.com:…它基于SSH密钥标识用户的url。(这是不允许的。)

So, I suspect (in decreasing order of likelihood) that one of the following is the case:

因此,我怀疑(按可能性递减的顺序)下面的情况是这样的:

  1. You created the mederot account previously and added your SSH key to it.
  2. 您之前创建了mederot帐户,并向其添加了SSH密钥。
  3. Someone else has obtained a copy of your public key and added it to the mederot GitHub account.
  4. 其他人已经获得了您的公钥副本并将其添加到mederot GitHub帐户。
  5. There's a horrible bug in GitHub.
  6. GitHub上有一个可怕的bug。

If 1 isn't the case then I would report this to GitHub, so they can check about 2 or 3.

如果不是1,我就会报告给GitHub,这样他们就可以检查2或3个。

More :

更多:

ssh-add -l check if there is more than one identify exists if yes, remove it by ssh-add -d "that key file"

ssh-add -l检查是否存在多个标识如果存在,通过ssh-add -d“那个键文件”删除它

#2


106  

After Googling for few days, I found this is the only question similar to my situation.

在谷歌上搜索了几天之后,我发现这是唯一一个和我的情况类似的问题。

However, I just solved the problem! So I am putting my answer here to help anyone else searching for this issue.

但是,我刚刚解决了这个问题!所以我把我的答案写在这里,以帮助其他搜索这个问题的人。

Here is what I did:

  1. Open "Keychain Access.app" (You can find it in Spotlight or LaunchPad)

    打开“钥匙链访问。应用程序(你可以在Spotlight或LaunchPad中找到它)

  2. Select "All items" in Category

    在类别中选择“所有项目”

  3. Search "git"

    搜索“git”

  4. Delete every old & strange item

    删除所有旧的和奇怪的东西

  5. Try to Push again and it just WORKED

    再推一次,就成功了

#3


46  

If problem is coming on windows then remove the Credentials from the Windows history.

如果windows出现问题,那么从windows历史记录中删除凭据。

  • Go to Credential Manager
  • 去证书管理器
  • Go to Windows Credentials
  • 去Windows凭据
  • Delete the entries under Generic Credentials
  • 删除通用凭证下的条目
  • Try connecting again.This time , it should prompt you for the correct username and password.
  • 尝试再次连接。这一次,它应该提示您输入正确的用户名和密码。

enter image description here enter image description here

remove credentials from git

从git删除凭证

#4


11  

Its due to a conflict.

这是由于冲突造成的。

Clear all keys from ssh-agent

清除所有来自ssh-agent的键

ssh-add -d ~/.ssh/id_rsa
ssh-add -d ~/.ssh/github

Add the github ssh key

添加github ssh密钥

ssh-add   ~/.ssh/github

It should work now.

现在应该工作。

#5


6  

On Mac, if you have multiple GitHub logins and are not using SSH, force the correct login by using:

在Mac上,如果您有多个GitHub登录,并且没有使用SSH,请使用以下命令强制正确登录:

git remote set-url origin https://username@github.com/username/repo-name.git

This also works if you're having issues pushing to a private repository.

如果您在向私有存储库推进时遇到问题,这也可以工作。

#6


5  

I find the solution is the same as @spyar provide which is the Keychain Access app stored the old username.

我发现解决方案和@spyar提供的一样,这是Keychain访问应用程序存储的旧用户名。

There are 2 solutions for this situation:

对于这种情况有两种解决办法:

  1. Delete the info in Keychain Access by
    • Open Keychain Access app
    • 打开钥匙链访问应用程序
    • Search for github
    • 寻找github
    • Delete corresponding credentials
    • 删除对应的凭证
  2. 通过打开Keychain Access app搜索删除Keychain Access中的信息,github删除相应的凭证

Or

  1. If you use want to use ssh key. You just change your Repo url from https
  2. 如果要使用ssh密钥。您只需从https更改Repo url

https://github.com/username/repo.git

https://github.com/username/repo.git

into

git@github.com:username/repo.git

git@github.com:用户名/ repo.git

Hope this helps.

希望这个有帮助。

#7


4  

I am using Mac and the issue is solved by deleting github record from keychain access app: Here is what i did:

我正在使用Mac,通过从keychain access app中删除github记录解决了这个问题:

  1. Open "Keychain Access.app" (You can find it in Spotlight orLaunchPad)
  2. 打开“钥匙链访问。app(你可以在Spotlight或launchpad中找到)
  3. Select "All items" in Category
  4. 在类别中选择“所有项目”
  5. Search "git"
  6. 搜索“git”
  7. Delete every old & strange items Try to Push again and it just WORKED
  8. 删除所有的旧的和奇怪的项目尝试再次推动,它只是工作

Above steps are copied from @spyar for the ease.

上面的步骤是从@spyar复制的。

#8


1  

I had the same problem as you. After a long time spent Googling, I found out my error was caused by multiple users that had added the same key in their accounts.

我和你有同样的问题。在搜索了很长一段时间之后,我发现我的错误是由多个用户在他们的账户中添加了相同的密钥造成的。

So, here is my solution: delete the wrong-user's ssh-key (I can do it because the wrong-user is also my account). If the wrong-user isn't your account, you may need to change your ssh-key, but I don't think this gonna happen.

因此,我的解决方案是:删除错误用户的ssh-key(我可以这样做,因为错误用户也是我的帐户)。如果错误用户不是你的账户,你可能需要更改你的ssh-key,但我认为这不会发生。

And I think your problem may be caused by a mistyping error in your accounts name.

我认为你的问题可能是由于你的账户名写错了。

#9


0  

This problem is also caused by:

这个问题也由:

If you are on a mac/linux, and are using 'ControlMaster' in your ~/.ssh/config, there may be some ssh control master processes running.

如果你正在使用mac/linux,并且在你的~/中使用“ControlMaster”。ssh/config,可能有一些ssh控制主进程正在运行。

To find them, run:

找到他们,运行:

ps aux | grep '\[mux\]'

And kill the relevant ones.

杀死相关的人。

#10


0  

I too ran into this, what caused this for me is that while cloning the repo I was pushing my changes to, I picked up the clone URL from an incognito tab without signing in. (I am still clueless on how it effects). That for some reason led to git picking another user account. When i tried it again from a proper signed in page it worked like usual for me.

我也遇到过这种情况,对我来说,导致这种情况的原因是,在克隆我正在推送我的更改的repo时,我从一个隐身标签中获取克隆URL,而没有登录。(我仍然对它的效果一无所知)。出于某种原因,git选择了另一个用户帐户。当我从一个正式签名的页面再次尝试时,它对我来说就像往常一样。


推荐阅读
author-avatar
LKD2008_561
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有