我遇到了以下错误:

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

当前回答

连接到服务器时使用参数-A,例如:

ssh -A root@myhost

来自手册页:

-A Enables forwarding of the authentication agent connection.  
   This can also be specified on a per-host basis in a configuration file.

   Agent forwarding should be enabled with caution.  Users with the ability to bypass file permissions on the remote host (for the agent's
   UNIX-domain socket) can access the local agent through the forwarded 
   connection.  An attacker cannot obtain key material from the agent,
   however they can perform operations on the keys that enable them to
   authenticate using the identities loaded into the agent.

其他回答

我犯了一个非常重要且愚蠢的错误——没有在~/.ssh文件夹中生成密钥。在开始github上描述的所有步骤之前,请更改为~/.ssh。这解决了我的问题

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

同时检查您的远程URL。使用git@github...而不是https://协议。

在自定义端口上通过SSH查看GitExtensions和PuTTY。

让我提供另一种解决方案。如果您刚刚安装了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及更高的步骤。

我在Linux上遇到了同样的问题,下面是我所做的:

基本上,命令ssh-agent启动代理,但它并没有真正设置运行环境变量。它只是将这些变量输出到shell。

您需要:

eval `ssh-agent`

然后执行ssh-add。请参阅无法打开与身份验证代理的连接。

确保键入了'eval“$(ssh agent-s)”'而不是'eval”ssh agent-s“'