How do I access my SSH public key?

2019-03-07 19:13发布

I've just generated my RSA key pair, and I wanted to add that key to GitHub.

I tried cd id_rsa.pub and id_rsa.pub, but no luck. How can I access my SSH public key?

标签: git ssh rsa
17条回答
放荡不羁爱自由
2楼-- · 2019-03-07 20:00

If you are using Windows PowerShell, the easiest way is to:

cat ~/.ssh/id_<key-type-here>.pub | clip

That will copy the key to your clipboard for easy pasting.

So, in my instance, I use ed25519 since RSA is now fairly hackable:

cat ~/.ssh/id_ed25519.pub | clip

Because I find myself doing this a lot, I created a function and set a simple alias I could remember in my PowerShell profile (learn more about PowerShell profiles here. Just add this to your Microsoft.PowerShell_profile.ps1:

function Copy-SSHKey {
    Get-Content ~/.ssh/id_ed25519.pub | clip
}

Set_Alias -Name sshkey -Value Copy-SSHKey

Then, in a PowerShell console, run . $profile to load the functions. Then from now on all you will need to do is run sshkey, and then paste the key into wherever you need via the clipboard.

查看更多
啃猪蹄的小仙女
3楼-- · 2019-03-07 20:00

Open your id_dsa.pub or some_name.pub file with gedit and copy-paste the contents!

Just use:

~/.ssh$ gedit some_name.pub
查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-07 20:01

Open terminal nano ~/.ssh/id_rsa.pub

查看更多
女痞
5楼-- · 2019-03-07 20:03

If you're using windows, the command is:

type %userprofile%\.ssh\id_rsa.pub

it should print the key (if you have one). You should copy the entire result. If none is present, then do:

ssh-keygen -t rsa -C "your.email@example.com" -b 4096

查看更多
再贱就再见
6楼-- · 2019-03-07 20:04

If your .ssh folder does not have any id_rsa.pub file, you can create it with the ssh-keygen command.

查看更多
登录 后发表回答