添加SSH密钥后,Github上的身份验证失败

时间:2013-07-10 20:26:31

标签: github ssh

我致命:当我尝试将代码推送到我的仓库时,身份验证失败。我也在我的github帐户上添加了公钥。当我做 :     ssh -i git@github.com 我得到了     Hi amangupta052! You've successfully authenticated, but GitHub does not provide shell access.

有人可以帮忙吗? 感谢

1 个答案:

答案 0 :(得分:23)

这取决于您使用过的远程网址。

如果git remote -v返回:

https://github.com/username/reponame

然后你的ssh设置无关紧要。但这可行:

ssh://git@github.com:username/reponame

另一个原因与您的私钥相关联:如果它是密码短语保护,其中包含特殊字符,通常效果不佳。
See here for other ssh causes of failure


要替换名为origin的遥控器,请使用git remote命令:

git remote set-url origin ssh://git@github.com:username/reponame

(正如GitHub help page中关于changing the rmeote url所述)

中所述

如果你看到::

ssh: Could not resolve hostname github.com:amangupta052: 
     Name or service not known 
fatal: The remote end hung up unexpectedly

尝试使用非scp ssh语法:

git remote set-url origin ssh://git@github.com/username/reponame

(请注意“/”而不是:之后的“github.com

也许这会有效,如commented in this blog post

git remote set-url origin git@github.com:username/reponame

(类似scp的语法,但没有ssh://前缀)

作为I mention here,scp语法通常意味着~/.ssh/config文件可以正常工作。

相关问题