无法从远程计算机 ssh 到 github:我该怎么办?

无法从远程计算机 ssh 到 github:我该怎么办?

我正在通过 ssh 连接到远程服务器。我希望能够从远程服务器 ssh 到 github。

我不想把我的私钥放在远程服务器上,因为其他人可以访问该机器。

当我尝试从远程服务器 ssh 到 github 时,出现以下错误:https://stackoverflow.com/questions/24961682/github-permission-denied-message-even-though-key-has-been-added

我已在本地计算机上设置以下内容~/.ssh/config,但没有帮助:

Host remoteHost
    ForwardAgent yes

我可以在远程机器上设置新的密钥对并将其添加到 github 吗?或者这会破坏我从本地机器 ssh 到远程机器的能力吗?

答案1

如果您不喜欢,则不必复制 ssh 密钥,您可以使用 -A 转发本地密钥

 -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 -At user@server

或者有时我什至必须跳到另一个主机,这样我就可以像这样运行它,

ssh -At user@server -- ssh -At user2@server2

答案2

您可以(并且应该)在远程计算机上生成新的 ssh 密钥,并使用他们的说明将其添加到 github:

https://help.github.com/articles/generate-ssh-keys

然后复制新生成的 ssh 密钥并将其添加到 github。

您的本地密钥不会受到影响。

相关内容