我遇到了以下错误:

$ 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文件夹中生成密钥。在开始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

其他回答

尝试以下操作:

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

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

当我试图让它在Windows上运行以通过SSH连接到存储库时,我也遇到了类似的问题。

这是对我有效的解决方案。

原来我在我的Windows盒子上运行Pageant ssh代理-我会检查你在运行什么。我怀疑它是Pageant,因为它是PuTTY和WinSCP的默认值。ssh add不能在命令行中使用这种类型的代理您需要通过Pageant UI窗口添加私钥,双击任务栏中的Pageant图标(启动后)即可获得该窗口。在将密钥添加到Pageant之前,需要将其转换为PPK格式。此处提供了完整的说明如何将SSH密钥转换为ppk格式就是这样。一旦我将密钥上传到存储库,我就可以使用Sourcetree创建本地存储库并克隆远程。

连接到服务器时使用参数-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.

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

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

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