我遇到了以下错误:

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

当前回答

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

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

其他回答

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

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

运行ssh代理的基本解决方案有很多答案。然而,多次运行ssh代理(每个打开的终端或每个远程登录)将创建内存中运行的ssh代理的多个副本。建议避免该问题的脚本很长,需要编写和/或复制分离的文件,或者需要在~/.profile或~/.src中编写太多字符串。让我建议简单的双字符串解决方案:

对于sh、bash等:

# ~/.profile
if ! pgrep -q -U `whoami` -x 'ssh-agent'; then ssh-agent -s > ~/.ssh-agent.sh; fi
. ~/.ssh-agent.sh

对于csh、tcsh等:

# ~/.schrc
sh -c 'if ! pgrep -q -U `whoami` -x 'ssh-agent'; then ssh-agent -c > ~/.ssh-agent.tcsh; fi'
eval `cat ~/.ssh-agent.tcsh`

这里有什么:

按名称和当前用户搜索进程ssh代理通过调用ssh代理创建适当的shell脚本文件,如果未找到当前用户ssh代理进程,则自行运行ssh代理评估已创建的配置适当环境的shell脚本

不必保护创建的shell脚本~/.sh-agent.tcsh或~/.sshagent.sh不受其他用户访问,因为:首先,与ssh代理的通信是通过受保护的套接字进行的,其他用户无法访问该套接字,其次,其他用户可以通过/tmp/目录中的枚举文件找到简单的ssh代理套接字。就访问ssh代理进程而言,这是相同的事情。

以下是我在使用PowerShell时提出的解决方案。

将以下函数添加到Microsoft.PowerShell_profile.ps1

function RunSsh($userIdentity ) {
   $agent=ssh-agent
   $position=$agent[0].IndexOf("=")
   $ending=$agent[0].IndexOf(";")

   $variableStartPosition=$agent[0].IndexOf("export")
   $variableEndPosition=$agent[0].LastIndexOf(";")
   $variableName=$agent[0].Substring($variableStartPosition+7,$variableEndPosition-$variableStartPosition-7)
   [Environment]::SetEnvironmentVariable($variableName, $agent[0].Substring($position+1,$ending-$position-1))

   $position=$agent[1].IndexOf("=")
   $ending=$agent[1].IndexOf(";")

   $variableStartPosition=$agent[1].IndexOf("export")
   $variableEndPosition=$agent[1].LastIndexOf(";")
   $variableName=$agent[1].Substring($variableStartPosition+7,$variableEndPosition-$variableStartPosition-7)
   [Environment]::SetEnvironmentVariable($variableName, $agent[1].Substring($position+1,$ending-$position-1))

   if($userIdentity.Length -eq 0) {
      ssh-add
   } else {
      ssh-add $userIdentity
   }
}

现在,您可以从命令行运行RunSsh,它使用~\.ssh文件夹中的标识文件,或者使用RunSsh C:\ssh\id_rsa传递标识文件,其中C:\ssh\ id_rsa是您的标识文件。

要实现这一点,您需要在路径环境变量中使用ssh-add和ssh-agent。

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

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

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

sudo vim /etc/hosts

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

18.205.93.2 bitbucket.org

然后就能解决问题

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

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