我遇到了以下错误:

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

当前回答

这对我有用。

在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

其他回答

这对我有用。

在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

如果你遵循这些指示,你的问题就会解决。

如果您在Mac或Linux计算机上,请键入:

eval "$(ssh-agent -s)"

如果您在Windows计算机上,请键入:

ssh-agent -s

这将只在您第一次需要时运行SSH代理并进行身份验证,而不是每次打开Bash终端时。它可以用于一般使用SSH的任何程序,包括SSH本身和scp。只需将其添加到/etc/profile.d/ssh-helper.sh:

ssh-auth() {
    # Start the SSH agent only if not running
    [[ -z $(ps | grep ssh-agent) ]] && echo $(ssh-agent) > /tmp/ssh-agent-data.sh

    # Identify the running SSH agent
    [[ -z $SSH_AGENT_PID ]] && source /tmp/ssh-agent-data.sh > /dev/null

    # Authenticate (change key path or make a symlink if needed)
    [[ -z $(ssh-add -l | grep "/home/$(whoami)/.ssh/id_rsa") ]] && ssh-add
}

# You can repeat this for other commands using SSH
git() { ssh-auth; command git "$@"; }

注:这是对这个问题的回答,它已经与这个问题合并。这个问题是针对Windows 7的,这意味着我的答案是针对Cygwin/MSYS/MSYS2的。这一点似乎适用于某些Unix,我不希望SSH代理需要这样管理。

尝试执行以下步骤:

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

在Windows 10中,使用命令提示符终端,以下功能适用于我:

ssh-agent cmd 
ssh-add

然后应要求您在此之后输入密码:

Enter passphrase for /c/Users/username/.ssh/id_rsa: