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

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


当前回答

开放式终端nano~/.ssh/id_rsa.pub

其他回答

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

cat ~/.ssh/id_rsa.pub | pbcopy

ssh-add用于显示公钥。

man ssh添加

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

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

ssh-add -L | xclip

以下是我如何在OS X上找到我的:

打开终端(您位于主目录中)cd.ssh(隐藏目录)pbcopy<id_rsa.pub(将其复制到剪贴板)

如果这不起作用,请执行ls并查看扩展名为.pub的文件。

使用gedit打开id_dsa.pub或some_name.pub文件并复制粘贴内容!

只需使用:

~/.ssh$ gedit some_name.pub

将密钥复制到剪贴板。

$ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

警告:在不添加换行或空白。谢天谢地,pbcopy命令使完美地执行此设置。

并将其粘贴到需要的位置。

有关该过程的更多详细信息,请参阅:生成SSH密钥。