我遇到了以下错误:

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

当前回答

尝试以下操作:

ssh-agent sh -c 'ssh-add && git push heroku master'

其他回答

尝试执行以下步骤:

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

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

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

对于Windows用户,我发现cmd eval“ssh agent-s”不起作用,但使用Git Bash效果不错:

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

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

阅读用户456814的答案以获得解释。这里我只尝试自动修复。

如果您在Bash中使用Cygwin终端,请将以下内容添加到$HOME/.bashrc文件中。这只会在第一个Bash终端中启动一次ssh代理,并将密钥添加到ssh代理。(我不确定Linux上是否需要这样做。)

###########################
# start ssh-agent for
# ssh authentication with github.com
###########################
SSH_AUTH_SOCK_FILE=/tmp/SSH_AUTH_SOCK.sh
if [ ! -e $SSH_AUTH_SOCK_FILE ]; then
    # need to find SSH_AUTH_SOCK again.
    # restarting is an easy option
    pkill ssh-agent
fi
# check if already running
SSH_AGENT_PID=`pgrep ssh-agent`
if [ "x$SSH_AGENT_PID" == "x" ]; then
#   echo "not running. starting"
    eval $(ssh-agent -s) > /dev/null
    rm -f $SSH_AUTH_SOCK_FILE
    echo "export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" > $SSH_AUTH_SOCK_FILE
    ssh-add $HOME/.ssh/github.com_id_rsa 2>&1 > /dev/null
#else
#   echo "already running"
fi
source $SSH_AUTH_SOCK_FILE

不要忘记在“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