我遇到了以下错误:

$ 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 7和Git Bash。

eval $(ssh-agent)

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

其他回答

以下是我在使用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。

我刚开始工作。打开~/.ssh/config文件。

附加以下内容-

Host github.com
 IdentityFile ~/.ssh/github_rsa

给我提示的页面为Git设置SSH说单空格缩进很重要。。。尽管我在Heroku有一个配置,它没有足够的空间,工作正常。

让我提供另一种解决方案。如果您刚刚安装了Git 1.8.2.2或更高版本,并且希望启用SSH,请遵循写得好的说明。

一直到步骤5.6,您可能会遇到一个小障碍。如果SSH代理已经在运行,则在重新启动bash时可能会收到以下错误消息

Could not open a connection to your authentication agent

如果需要,请使用以下命令查看是否有多个ssh代理进程正在运行

ps aux | grep ssh

如果看到多个ssh代理服务,则需要终止所有这些进程。按如下方式使用kill命令(PID在您的计算机上是唯一的)

kill <PID>

例子:

kill 1074

删除所有ssh代理进程后,再次运行px aux | grep ssh命令以确保它们已删除,然后重新启动Bash。

瞧,你现在应该得到这样的东西:

Initializing new SSH agent...
succeeded
Enter passphrase for /c/Users/username/.ssh/id_rsa:

现在,您可以继续执行步骤5.7及更高的步骤。

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

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

对于内置于Windows 10中的Bash,我将其添加到文件.Bash_profile中:

if [ -z $SSH_AUTH_SOCK ]; then
    if [ -r ~/.ssh/env ]; then
            source ~/.ssh/env
            if [ `ps -p $SSH_AGENT_PID | wc -l` = 1 ]; then
                    rm ~/.ssh/env
                    unset SSH_AUTH_SOCK
            fi
    fi
fi

if [ -z $SSH_AUTH_SOCK ]; then
    ssh-agent -s | sed 's/^echo/#echo/'> ~/.ssh/env
    chmod 600 ~/.ssh/env
    source ~/.ssh/env > /dev/null 2>&1
fi