我遇到了以下错误:

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

当前回答

我通过强制停止(终止)git进程(ssh代理),然后卸载git,然后再次安装git来解决这个错误。

其他回答

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

eval $(ssh-agent)

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

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

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

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

sudo vim /etc/hosts

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

18.205.93.2 bitbucket.org

然后就能解决问题

对于内置于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

以下命令对我有效。我使用的是CentOS。

exec ssh-agent bash

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

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

猛击:

$ 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