我尝试过谷歌搜索并通读 https://help.github。 com/en/articles/connecting-to-github-with-ssh 和各种指南。我无法git push -u origin master
或git push origin master
(相同的命令)。
我的 git 帐户已经使用至少两年左右了。我已经成功地在我的笔记本电脑上创建了存储库并 push -u origin master
,但在这个台式机上我遇到了问题。
这是我尝试过的:
1.我已经设置了我的 git 用户名
2.我已经设置了我的 git 用户电子邮件
3.我已经上传了我的 /home/meder/.ssh/id_rsa.pub 的内容到 github 的帐户页面。我已验证我没有粘贴任何空格
4。 我已使用以下内容创建了 ~/.ssh/config:
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
我已将 .ssh chmodded 为 700,id_rsa 600
5。强>我已经添加了正确的远程源没有输入错误:git远程添加源[电子邮件受保护]:medero/cho.git
6 .为了确认#5,这是我的 .git/config。该目录正确,而不是另一个目录:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:medero/cho.git
7. ssh [email protected] -v
给了我一个成功的身份验证
8.一件奇怪的事情是,它向我打招呼的用户名后面附加了t
。我的 github 用户名是 medero
,而不是 medert
。
嗨梅德罗!你已经成功了
经过身份验证,但 GitHub 没有
提供 shell 访问。
9. 我不在代理或防火墙后面
10. 提供了密钥,这是 -v
:
debug1:主机“github.com”已知并且与 RSA 主机密钥匹配。
debug1:在 /home/meder/.ssh/known_hosts:58 中找到密钥
debug1:ssh_rsa_verify:签名正确
debug1:SSH2_MSG_NEWKEYS 已发送
debug1:期待 SSH2_MSG_NEWKEYS
debug1:收到 SSH2_MSG_NEWKEYS
debug1:已发送 SSH2_MSG_SERVICE_REQUEST
debug1:收到 SSH2_MSG_SERVICE_ACCEPT
debug1:可以继续的身份验证:publickey
debug1:下一个身份验证方法:publickey
debug1:提供公钥:/home/meder/.ssh/id_rsa
debug1:远程:强制命令:gerve mederot
debug1:远程:端口转发已禁用。
debug1:远程:X11 转发已禁用。
debug1:远程:代理转发已禁用。
debug1:远程:Pty 分配已禁用。
debug1:服务器接受密钥:{一些东西,不知道我是否应该分享它
debug1:远程:强制命令:gerve mederot
debug1:远程:端口转发已禁用。
debug1:远程:X11 转发已禁用。
debug1:远程:代理转发已禁用。
debug1:远程:Pty 分配已禁用。
debug1:身份验证成功(公钥)。
11. 以下是我使用的命令
mkdir cho
git init
touch README
git add README
git commit -m 'test'
git remote add origin [email protected]:medero/cho.git
git push -u origin master
12. 我不想创建新的 SSH 密钥。
13. 如果我使用 ssh 进行 git clone 并进行编辑、提交和 git Push,我会得到同样的结果。
14. 这是实际的错误:
$ git push
ERROR: Permission to medero/cho.git denied to mederot.
fatal: The remote end hung up unexpectedly
15. 我已经设置了我的 github 用户名和 github 令牌:
$ git config --global github.user medero
$ git config --global github.token 0123456789yourf0123456789token为系统上的所有 git 实例设置 GitHub 令牌
16。 我已确认我的 github 用户名不是 mederot
而我的 github 令牌是根据我的帐户页面正确(已验证前 2 个字符和最后 2 个字符)。
17。为了确认#16,~/.gitconfig包含
[github]
token = mytoken...
user = medero
18。我做了ssh-key add ~/.ssh/id_rsa
如果这是偶数必要...
理论:
我怀疑有什么可疑之处,因为当我通过 ssh 身份验证时,用户问候语是 mederot
而不是 medero
,这是我的帐户。我的 github 帐户中的某些内容是否可能被错误缓存?
我还怀疑本地 ssh 缓存有一些奇怪的地方,因为如果我 mv ~/.ssh/id_rsa KAKA
和 mv ~/.ssh/id_rsa.pub POOPOO
,并执行 ssh [电子邮件受保护] -v
,当我重命名它时,它仍然对我进行身份验证并说它为我的 /home/meder/.ssh/id_rsa 提供服务?!一定要缓存吗?!
I have tried googling and read through https://help.github.com/en/articles/connecting-to-github-with-ssh and various, various guides. I am unable to git push -u origin master
or git push origin master
( the same command ).
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.
Here's what I tried:
1. I have setup my git user name
2. I have setup my git user email
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
4. I have created a ~/.ssh/config with these contents:
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
I have chmodded the .ssh to 700, id_rsa 600
5. I have added the proper remote origin without making typos : git remote add origin [email protected]:medero/cho.git
6. To confirm #5, here is my .git/config. The directory is correct and not another directory:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = [email protected]:medero/cho.git
7. ssh [email protected] -v
gives me a successful Authentication
8. One weird thing is, the username which it greets me with has t
appended to it. My github username is medero
, not medert
.
Hi mederot! You've successfully
authenticated, but GitHub does not
provide shell access.
9. I am not behind a proxy or firewall
10. The key is offered, heres the output from -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
mkdir cho
git init
touch README
git add README
git commit -m 'test'
git remote add origin [email protected]:medero/cho.git
git push -u origin master
12. I don't want to create a new SSH key.
13. If I git clone using ssh and make an edit, commit, and git push, I get the same exact thing.
14. Here's the actual error:
$ 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:
$ git config --global github.user medero
$ git config --global github.token 0123456789yourf0123456789tokenSets the GitHub token for all git instances on the system
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 ).
17. To confirm #16, ~/.gitconfig contains
[github]
token = mytoken...
user = medero
18. I did ssh-key add ~/.ssh/id_rsa
if that's even necessary...
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?
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 [email protected] -v
, it still Authenticates me and says it serves my /home/meder/.ssh/id_rsa when I renamed it?! It has to be cached?!
发布评论
评论(20)
经过几天的谷歌搜索,我发现这是唯一与我的情况相似的问题。
不过,我刚刚解决了这个问题!因此,我将我的答案放在这里,以帮助其他搜索此问题的人。
这是我所做的:
打开“Keychain Access.app”(您可以在 Spotlight 或 LaunchPad 中找到它)
在类别中选择“所有项目”
搜索“git”
删除所有旧的和新的内容。奇怪的项目
再次尝试推送,它就成功了
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:
Open "Keychain Access.app" (You can find it in Spotlight or LaunchPad)
Select "All items" in Category
Search "git"
Delete every old & strange item
Try to Push again and it just WORKED
如果 Windows 出现问题,请从 Windows 历史记录中删除凭据。
从 git 删除凭据
If problem is coming on windows then remove the Credentials from the Windows history.
remove credentials from git
在 Mac 上,如果您有多个 GitHub 登录名并且不使用 SSH,请使用以下命令强制正确登录:
如果您在推送到私有存储库时遇到问题,这也适用。
On Mac, if you have multiple GitHub logins and are not using SSH, force the correct login by using:
This also works if you're having issues pushing to a private repository.
在第 18 步中,我假设您的意思是
ssh-add ~/.ssh/id_rsa
?如果是这样,那就解释了:...因为 ssh-agent 正在缓存您的密钥。
如果你查看 GitHub,就会发现有一个 mederot 帐户。你确定这件事与你无关吗? GitHub 不应允许将相同的 SSH 公钥添加到两个帐户,因为当您使用
[电子邮件受保护]:...
它根据 SSH 密钥识别用户的 URL。 (此处确认不允许这样做.)因此,我怀疑(按可能性降序排列)存在以下情况之一:
如果 1 不是这种情况,那么我会将其报告给 GitHub,以便他们可以检查大约 2 或 3。
更多:
ssh-add -l 检查是否存在多个标识
如果是,通过 ssh-add -d "that key file" 删除它
In step 18, I assume you mean
ssh-add ~/.ssh/id_rsa
? If so, that explains this:... since the
ssh-agent
is caching your key.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
[email protected]:...
URLs it's identifying the user based on the SSH key. (That this shouldn't be allowed is confirmed here.)So, I suspect (in decreasing order of likelihood) that one of the following is the case:
If 1 isn't the case then I would report this to GitHub, so they can check about 2 or 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-agent 中的所有密钥
添加 github ssh 密钥
现在应该可以工作了。
Its due to a conflict.
Clear all keys from ssh-agent
Add the github ssh key
It should work now.
我使用的是 Mac,通过从钥匙串访问应用程序中删除 github 记录解决了该问题:
这就是我所做的:
以上步骤是从@spyar复制的,以方便起见。
I am using Mac and the issue is solved by deleting github record from keychain access app:
Here is what i did:
Above steps are copied from @spyar for the ease.
我发现解决方案与 @spyar 提供的解决方案相同,即存储旧用户名的钥匙串访问应用程序。
对于这种情况有两种解决方案:
或
如果您想使用ssh密钥。您只需将您的 Repo url 从 https 更改为
<块引用>
https://github.com/username/repo.git
进入
<块引用>
[电子邮件受保护]:用户名/repo.git
I find the solution is the same as @spyar provide which is the Keychain Access app stored the old username.
There are 2 solutions for this situation:
Or
If you want to use ssh key. You just change your Repo url from https
into
我在 Mac 操作系统上遇到了类似的问题。
摘要
git push https://[email protected]/username/repository.git
并提供 PAT 作为密码有关我的设置/情况/问题的更多详细信息
本质上,我试图使用两个不同的 GitHub (github.com) 帐户(1. 工作帐户/电子邮件 & 2. 个人帐户/我
的情况有点特殊,因为在将我们的存储库迁移到公共 github.com 之前,当我们的组织在本地时,我有一个使用我的个人电子邮件生成的现有 SSH 密钥,并且该密钥也是为 Bastion AWS(Amazon Web Services)配置的。我无法使用同一电子邮件重新生成新密钥,也没有使用工作电子邮件生成新密钥,这需要更新为 Bastion AWS 配置的密钥
注意:我的初始设置本身不正确,因为当时我对如何使用或使用 SSH 密钥不太了解,所以我意识到我设置不正确
以下方法对我有用(请注意,这是一个解决方法)。我转而使用 GitHub 个人访问令牌 (PAT)。
提示密码时,我在这里输入了我的 PAT(然后将其缓存到 OSX Keychain Access),
然后
在我后续的推送中,没有密码提示,并且我不必使用完整的 URL 来推送。只需 git push 即可 工作正常
I was running into similar issue on Mac OS.
Summary
git clone https://[email protected]/username/repository.git
git push https://[email protected]/username/repository.git
and providing PAT as passwordgit push <origin/remote/upstream> <branch>
worked fineMore details about my set up/situation/issue
Essentially I was trying to work with two different GitHub (github.com) accounts (1. Work account/email & 2. Personal account/email)
Mine was a little peculiar case because I had an existing SSH key generated with my personal email when our organization was on premise before migrating our repos to public github.com and that key was also configured for Bastion AWS (Amazon Web Services). I couldn't regenerate a new key with the same email and also I did not generate a new key with work email which would have required to update the key configured for Bastion AWS
Note: My initial set up itself wasn't correct because at that time I didn't have much knowledge about how to work with or use SSH keys, so I realized I set them up incorrectly
Following approach worked for me (Note that this is a work around). I fell back to using GitHub Personal Access Token (PAT) instead.
Prompted password, I entered my PAT here (which then got cached to OSX Keychain Access)
And then
On my subsequent pushes, no password prompts and I didn't have to use the full URL to push. Just
git push <origin/remote/upstream> <branch>
worked fine我最近在我的机器上的旧存储库上遇到了这个问题,该存储库是使用 https 推送的。步骤 5 和 6 通过将我的存储库的远程 url 从使用 https url 重新设置为 ssh url 解决了我的问题,
检查远程是否使用 https url,
然后重新设置源以使用 ssh url
验证新的远程
现在可以成功
git push -u origin
我仍然不确定我会更改哪些设置,这可能会导致远程为 https 时推送失败,但这是我的问题的解决方案
I recently ran into this issue for on old repo on my machine that had been pushed up using https. steps 5 and 6 solved my issue by re-setting the remote url for my repo from using the https url to the ssh url
checking the remote is using the https url
then re-setting the origin to use the ssh url
verifying new remote
could now successfully
git push -u origin
i'm still not sure what setting i would have changed that might have caused the push to fail when the remote is https but this was the solution to my issue
我和你有同样的问题。经过很长时间的谷歌搜索后,我发现我的错误是由多个用户在其帐户中添加了相同的密钥引起的。
所以,这是我的解决方案:删除错误用户的 ssh 密钥(我可以这样做,因为错误用户也是我的帐户)。如果错误的用户不是您的帐户,您可能需要更改您的 ssh 密钥,但我认为这种情况不会发生。
我认为您的问题可能是由于您的帐户名称输入错误造成的。
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.
And I think your problem may be caused by a mistyping error in your accounts name.
我在使用 Travis CI 部署内容时遇到此错误,其中涉及推送编辑到存储库。
我最终通过使用
个人访问令牌 解决了该问题>public_repo
范围访问权限:I encountered this error when using Travis CI to deploy content, which involved pushing edits to a repository.
I eventually solved the issue by updating the GitHub personal access token associated with the Travis account with the
public_repo
scope access permission:在推送到存储库时观察到同样的问题:
所做的就是确保克隆您的分叉存储库:
并且它起作用了:
怀疑一开始,它没有使用分叉存储库,而是使用了来自 redhat 的存储库,这可以解释由于
cniackz
用户无权访问该存储库,而只能访问 fork,因此出现此问题。Same issue was observed when pushing to a respository:
What was done is making sure you clone your forked repository:
And it worked:
It is suspected that to start with, it was not used the forked repository but the one from redhat and this would explain the issue since
cniackz
user does not have access to that repository but to forked only.就我而言,我的两个帐户有两个不同的 ssh 密钥。一种用于工作,一种用于个人 github 帐户。我通过更改 .ssh/config 文件和 git 远程 url 解决了这个问题。
起初我的 .ssh/config 文件如下所示:
我的 git 远程 url 是 [email protected]:myusername/my-repo-name.git
然后首先我改变了.ssh/config 文件添加两个主机,如下所示:
并将 git 远程 url 替换为 git_personal:myusername/my-repo-name.git 通过替换 "[email protected]" 和“git_personal”是我在配置文件中提供的主机名。
但它仍然不起作用,然后我只是从 .ssh/config 中删除“Host *”相关部分,它就起作用了。所以最后我的 .ssh/config 如下所示:
然后最后错误消失了并且它起作用了。如果有像我这样的情况,希望有人能从中受益。
In my case, I had two different ssh key for two account. One was for work and one was for personal github account. I resolved it by changing the .ssh/config file and git remote url.
At first my .ssh/config file was like below:
And my git remote url was [email protected]:myusername/my-repo-name.git
Then first I changed the .ssh/config file with adding two hosts like following:
And git remote url to git_personal:myusername/my-repo-name.git by replacing "[email protected]" with "git_personal" the hostname that I gave in config file.
But still it was not work then I just remove the "Host *" related portion from the .ssh/config the it worked. So at last my .ssh/config was like below:
Then finally the error was gone and it worked. Hopefully someone may benefit from it if there case is similar like me.
这个问题也是由以下原因引起的:
如果您使用的是 mac/linux,并且在 ~/.ssh/config 中使用“ControlMaster”,则可能有一些 ssh 控制主进程正在运行。
要找到它们,请运行:
并杀死相关的。
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.
To find them, run:
And kill the relevant ones.
我也遇到了这个问题,对我来说造成这个问题的原因是,在克隆我正在推送更改的存储库时,我在没有登录的情况下从隐身选项卡中获取了克隆 URL。(我仍然不知道它是如何影响的)。由于某种原因,这导致 git 选择另一个用户帐户。
当我从正确的登录页面再次尝试时,它对我来说就像平常一样。
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.
我在使用 MAC 时也碰巧遇到了这个问题
所以,问题是这样的。我曾经从我的旧 GitHub 帐户之一登录过。现在,我使用不同的 GitHub 帐户。
我使用以下步骤解决了 -
再次尝试 Push 就可以了
I also happen to come across this issue while working on my MAC
So, the problem is this. I had once logged in from one of my old GitHub account. Now, I am using a different GitHub account.
I solved using the below steps-
Try to Push again and it will work
对我有帮助的步骤:
对我来说,这一步是错误的根源,因为我正确地遵循了上面的步骤 1。
这就是我的想法。
Steps that help me:
For me this step was the source for the error, since I followed the above step 1 correctly.
That's all I think.
我在尝试从组织克隆私有存储库时遇到了这个问题。就我而言,解决方案是从 GitHub 中删除 SSH 密钥并添加一个新密钥。
I ran into this issue when trying to clone a private repository from an organization. In my case the solution was to delete the SSH key from GitHub and add a new one.
就我而言,我只是没有被添加到我想要贡献其存储库的组织中,其他一切都已设置完毕。所以我要求组织所有者添加我,结果成功了。
In my case, I simply wasn't added to the organization whose repository I want to contribute to, everything else was set up. So I asked the organisation owner to add me, and it worked.
错误搜索目的:
错误:远程:USERNAME-2 对 USERNAME-1/REPONAME.git 的权限被拒绝。
致命:无法访问“https://github.com/USERNAME-1/repo.git/”:
请求的 URL 返回错误:403
错误:无法将某些引用推送到 'https://github.com/user/repo.git
错误:您无权推送到 github 上的“repo”。你是否想要
创建一个叉子并推入它,而不是
我遇到了这个错误^。所以我遵循这个对我有用。
我的解决方案:
我删除了所有 .git 或 git 凭据。没有别的。
希望这对流浪的同伴有所帮助。
ERROR SEARCH PURPOSES:
error: remote: Permission to USERNAME-1/REPONAME.git denied to USERNAME-2.
fatal: unable to access 'https://github.com/USERNAME-1/repo.git/': The
requested URL returned error: 403
error: failed to push some refs to 'https://github.com/user/repo.git
error: you dont have permission to push to "repo" on github. would you like to
create a fork and push to it instead
I had this error ^. so i followed this and it worked for me.
my solution:
i deleted all .git or git credentials. nothing else.
hope this helps a fellow wanderer.