我遇到了以下错误:

$ 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.

当前回答

甚至在生成和添加SSH密钥时运行命令时,我也收到了“无法打开到您的身份验证代理的连接”:SSH-add~/.SSH/id_rsa。

我通过停止在我的计算机上运行的多个ssh代理实例来解决这个问题,然后从我的Windows计算机上的控制面板卸载Git,然后再次安装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.

我在Linux上遇到了同样的问题,下面是我所做的:

基本上,命令ssh-agent启动代理,但它并没有真正设置运行环境变量。它只是将这些变量输出到shell。

您需要:

eval `ssh-agent`

然后执行ssh-add。请参阅无法打开与身份验证代理的连接。

我遇到的一件事是,eval对我使用Cygwin不起作用,对我起作用的是ssh代理ssh add id_rsa。

之后,我遇到了一个问题,我的私钥太开放了,我设法找到了解决方案(从这里):

chgrp Users id_rsa

以及

chmod 600 id_rsa

最后我能够使用:

ssh-agent ssh-add id_rsa

我在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密码。

“代理转发”是一种可以帮助您解决问题的技术。这使得本地SSH密钥在服务器内的活动会话期间“可用”。

如果您在Windows上使用PuTTY,则需要将“Connection/SSSH/Auth/Allow-agent forwarding”选项设置为“true”。