我刚刚生成了RSA密钥对,我想将该密钥添加到GitHub。

我尝试了cd id_rsa.pub和id_rsa.php,但没有成功。如何访问SSH公钥?


当前回答

ssh-add用于显示公钥。

man ssh添加

-L  Lists public key parameters of all identities currently repre‐
    sented by the agent.

在我的Linux系统上,我使用xclip复制它

ssh-add -L | xclip

其他回答

您可以尝试运行以下命令以显示RSA指纹:

ssh-agent sh -c 'ssh-add; ssh-add -l'

或公钥:

ssh-agent sh -c 'ssh-add; ssh-add -L'

如果您收到消息:“代理没有身份。”,然后必须首先通过ssh-keygen生成RSA密钥。

cat~/.ssh/id_rsa.pub或cat~//ssh/id_dsa.pub

您可以通过以下操作列出所有公钥:

$ls~/.ssh/*.pub

如果只有私钥可用,则可以从中生成公钥:

ssh-keygen -y

or

ssh-keygen -y -f path/to/private_key

以下命令将SSH密钥保存在剪贴板上。您只需在所需位置粘贴即可。

cat ~/.ssh/id_rsa.pub | pbcopy

为了给这个问题一个新的视角,如果你使用github,你可以在以下位置找到你的公钥:https://github.com/${USERNAME}.keys