【发布时间】:2011-07-17 03:38:33
【问题描述】:
我尝试使用谷歌搜索并阅读https://help.github.com/en/articles/connecting-to-github-with-ssh 和各种指南。我无法git push -u origin master 或git push origin master(相同的命令)。
我拥有我的 git 帐户至少 2 年左右。我已经成功地在我的笔记本电脑上创建了 repos 和 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 修改为 700,id_rsa 600
5.我添加了正确的远程来源没有打错字:git remote add origin git@github.com:medero/cho.git
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 给我一个成功的身份验证
8. 一件奇怪的事情是,它向我打招呼的用户名附加了t。我的 github 用户名是 medero,而不是 medert。
你好梅德罗!你已经成功 已通过身份验证,但 GitHub 没有 提供外壳访问。
9.我没有在代理或防火墙之后
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.这是我使用的命令
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.我不想创建新的 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 git@github.com -v,它仍然对我进行身份验证并说它在我重命名它时为我的 /home/meder/.ssh/id_rsa 服务?!一定要缓存?!
【问题讨论】:
-
我正在使用“Github for Windows”,在两个 Github 帐户之间切换时遇到了类似的问题。这是我的解决方案:stackoverflow.com/questions/18565876/…
-
如果您希望从 2 个不同的本地仓库推送到其对应的原始远程仓库,请检查:stackoverflow.com/q/63291726/12033855