我遇到了以下错误:

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

当前回答

当我试图让它在Windows上运行以通过SSH连接到存储库时,我也遇到了类似的问题。

这是对我有效的解决方案。

原来我在我的Windows盒子上运行Pageant ssh代理-我会检查你在运行什么。我怀疑它是Pageant,因为它是PuTTY和WinSCP的默认值。ssh add不能在命令行中使用这种类型的代理您需要通过Pageant UI窗口添加私钥,双击任务栏中的Pageant图标(启动后)即可获得该窗口。在将密钥添加到Pageant之前,需要将其转换为PPK格式。此处提供了完整的说明如何将SSH密钥转换为ppk格式就是这样。一旦我将密钥上传到存储库,我就可以使用Sourcetree创建本地存储库并克隆远程。

其他回答

我尝试了其他解决方案,但都没有效果。我做了更多的研究,发现以下命令有效。我正在使用Windows 7和Git Bash。

eval $(ssh-agent)

更多信息:https://coderwall.com/p/rdi_wq(web存档版本)

连接到服务器时使用参数-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代理-s,而是使用eval“ssh代理-s”来解决这个问题。

下面是我一步一步执行的操作(在GitBash上执行第2步):

清理了位于C:\user\<username>\.ssh的.ssh文件夹\生成了新的SSH密钥:ssh keygen-t rsa-b 4096-C“xyz@abc.com"检查是否有任何进程id(ssh代理)正在运行。ps aux | grep ssh(可选)如果在步骤3中发现任何错误,请清除这些错误杀死<pids>已启动SSH代理$eval` ssh代理-s `将步骤2中生成的SSH密钥添加到SSH代理ssh添加~/.ssh/id_rsa

Run

ssh-agent bash
ssh-add

要获取更多详细信息,您可以搜索

ssh-agent

或运行

man ssh-agent

尝试执行以下步骤:

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