我刚刚生成了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

其他回答

idrsa.pub不是一个目录,因此您不能使用cd打开它。

相反,您可以使用命令cd~/.ssh访问包含密钥的文件夹,然后使用cat idrsa.pub、nano idrsa.ub或gedit idrsa..pub访问密钥文件。

ssh-add用于显示公钥。

man ssh添加

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

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

ssh-add -L | xclip

如果您在Windows上,请使用以下选项,选择全部,然后从记事本窗口复制:

notepad ~/.ssh/id_rsa.pub  

如果您使用的是OS X,请使用:

pbcopy < ~/.ssh/id_rsa.pub

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

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

$ls~/.ssh/*.pub

Mac、Ubuntu、Linux兼容机器,使用此命令打印公钥,然后复制:

$ cat ~/.ssh/id_rsa.pub