我遇到了以下错误:

$ 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用户,我发现cmd eval“ssh agent-s”不起作用,但使用Git Bash效果不错:

eval `ssh-agent -s`; ssh-add KEY_LOCATION

并确保Windows服务“OpenSSH密钥管理”未被禁用。

其他回答

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

放大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工作所需的环境变量。

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

要解决此错误,请执行以下操作:

猛击:

$ eval `ssh-agent -s`

tcsh:

$ eval `ssh-agent -c`

然后像平常一样使用ssh-add。


热门提示:

我总是忘记为上面的ssh代理命令键入什么,所以我在.bashrc文件中创建了一个别名,如下所示:

alias ssh-agent-cyg='eval `ssh-agent -s`'

现在,我可以使用ssh代理cyg代替ssh代理

E.g.

$ ssh-agent-cyg
SSH_AUTH_SOCK=/tmp/ssh-n16KsxjuTMiM/agent.32394; export SSH_AUTH_SOCK;
SSH_AGENT_PID=32395; export SSH_AGENT_PID;
echo Agent pid 32395;
$ ssh-add ~/.ssh/my_pk

原始修复源:

http://cygwin.com/ml/cygwin/2011-10/msg00313.html

这对我有用。

在CMD窗口中,键入以下命令:

cd path-to-Git/bin # (for example,cd C:\Program Files\Git\bin)
bash
exec ssh-agent bash
ssh-add path/to/.ssh/id_rsa

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

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

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