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?
pub from the file name (in any instance). Remember id_rsa is the private key and id_rsa. pub is the public key. And that's all there is to viewing your SSH public and private keys on Linux, macOS, and Windows.
cat ~/.ssh/id_rsa.pub
or cat ~/.ssh/id_dsa.pub
You can list all the public keys you have by doing:
$ ls ~/.ssh/*.pub
Copy the key to your clipboard.
$ pbcopy < ~/.ssh/id_rsa.pub # Copies the contents of the id_rsa.pub file to your clipboard
Warning: it's important to copy the key exactly without adding newlines or whitespace. Thankfully the pbcopy command makes it easy to perform this setup perfectly.
and paste it wherever you need.
More details on the process, check: Generating SSH Keys.
Mac, Ubuntu, Linux compatible machines, use this command to print public key, then copy it:
$ cat ~/.ssh/id_rsa.pub
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 "[email protected]" -b 4096
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With