我遇到了以下错误:

$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.132' to the list of known hosts.
!  Your key with fingerprint b7:fd:15:25:02:8e:5f:06:4f:1c:af:f3:f0:c3:c2:65 is not authorized to access bitstarter.

我尝试添加密钥,但出现以下错误:

$ ssh-add ~/.ssh/id_rsa.pub
Could not open a connection to your authentication agent.

当前回答

我通过强制停止(终止)git进程(ssh代理),然后卸载git,然后再次安装git来解决这个错误。

其他回答

在我的情况下,我的Comodo防火墙已将ssh代理装箱。一旦我禁用了沙盒,我就能够克隆存储库。

仅供参考,我正在Windows 7上使用Comodo防火墙。

我在Ubuntu上遇到了同样的问题,其他的解决方案对我没有帮助。

我终于意识到我的问题是什么。我在/root/.SSH文件夹中创建了我的SSH密钥,所以即使我以root身份运行SSH-add,它也无法正常工作,一直在说:

无法打开与身份验证代理的连接。

我在/home/myUsername/文件夹中创建了SSH公钥和私钥

ssh-agent /bin/sh

然后我跑了

ssh-add /home/myUsername/.ssh/id_rsa

问题就这样解决了。

注意:要访问Git中的存储库,请在使用SSH keygen-t rsa-C“您的Git电子邮件”创建SSH密钥时添加Git密码。

连接到服务器时使用参数-A,例如:

ssh -A root@myhost

来自手册页:

-A Enables forwarding of the authentication agent connection.  
   This can also be specified on a per-host basis in a configuration file.

   Agent forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the agent's
   UNIX-domain socket) can access the local agent through the forwarded 
   connection.  An attacker cannot obtain key material from the agent,
   however they can perform operations on the keys that enable them to
   authenticate using the identities loaded into the agent.

MsysGit或Cygwin

如果您使用的是Msysgit或Cygwin,您可以在SSH代理中找到一个很好的教程:Msysgit、Cygwin和bash:

将名为.bashrc的文件添加到主文件夹。打开文件并粘贴到:#!/bin/basheval`ssh代理-s`ssh添加这假设您的密钥位于传统的~/.ssh/id_rsa位置。如果不是,请在ssh-add命令后包含完整路径。添加到或创建包含内容的文件~/.ssh/configForwardAgent是在最初的教程中,ForwardAgent参数是Yes,但它是一个拼写错误。使用小写字母,否则会出现错误。重新启动Msysgit。它会要求您输入一次密码,就这样(直到您结束会话,或者您的ssh代理被终止)

Mac/OS X

如果您不想在每次打开终端时启动新的ssh代理,请查看Keychain。我现在使用的是Mac,所以我在Mac OS X上使用了带有zsh&keychain的ssh代理教程来设置它,但我相信谷歌搜索会有很多关于Windows的信息。

更新:Mac上更好的解决方案是将密钥添加到Mac OS钥匙链:

ssh-add -K ~/.ssh/id_rsa

就这么简单。

这个解决方案很可能对你有用,再试一次

在我的例子中,它与DNS映射有关(bitbucket没有指向正确的IP)。我通过一个简单的技巧修复了它(在查找bitbucket.org时,我重写了IP地址)

在ubuntu中打开和编辑/etc/hosts(如果是任何其他操作系统,请查看如何做到这一点)

sudo vim /etc/hosts

并添加以下行(如果是GitHub或任何其他网站,请查找IP并相应地进行映射)

18.205.93.2 bitbucket.org

然后就能解决问题