我遇到了以下错误:

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

当前回答

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

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

其他回答

对于Windows中的PowerShell

我在使用PowerShell和Start-SshAgent/Add-SshKey命令时遇到了问题,所以我快速编写了一个脚本,可能会帮助一些人。这将添加到PowerShell配置文件中,您可以通过执行记事本$profile来编辑该配置文件:

if ($(Get-Process ssh-agent) -eq $null)
{
     $ExecutionContext.InvokeCommand.ExpandString($(ssh-agent -c).Replace("setenv", "set"));
}

它将检测ssh代理是否正在运行,并且仅在没有代理运行时执行。请注意,$ExecutionContext.InvokeCommand.ExpandString是一个非常危险的命令,因此如果您使用的是不受信任的ssh代理副本,则可能不希望使用此解决方案。

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

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

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

exec ssh-agent bash

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

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

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

我犯了一个非常重要且愚蠢的错误——没有在~/.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