我遇到了以下错误:

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

当前回答

放大n3o对Windows 7的回答。。。

我的问题是确实没有设置一些必需的环境变量,而n3o是正确的,ssh-agent会告诉您如何设置这些环境变量,但实际上并没有设置它们。

由于Windows不允许您执行“eval”,因此以下是替代方法:

将ssh代理的输出重定向到批处理文件

ssh-agent > temp.bat

现在使用记事本等文本编辑器编辑temp.bat。对于前两行中的每一行:

在行首插入单词“set”和空格。删除第一个分号和后面的所有内容。

现在删除第三行。您的temp.bat应该如下所示:

set SSH_AUTH_SOCK=/tmp/ssh-EorQv10636/agent.10636
set SSH_AGENT_PID=8608

运行temp.bat。这将设置ssh add工作所需的环境变量。

其他回答

连接到服务器时使用参数-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.

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

我通过停止在我的计算机上运行的多个ssh代理实例来解决这个问题,然后从我的Windows计算机上的控制面板卸载Git,然后再次安装Git,现在一切都正常了。

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

尝试执行以下步骤:

打开GitBash并运行:cd~/.ssh尝试运行agent:eval$(ssh代理)现在,您可以运行以下命令:ssh-add-l

尝试以下操作:

ssh-agent sh -c 'ssh-add && git push heroku master'