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?
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?
Mac, Ubuntu, Linux compatible machines, use this command to print public key, then copy it:
$ cat ~/.ssh/id_rsa.pub
On terminal cat ~/.ssh/id_rsa.pub
explanation
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
The following command will save the SSH key on the clipboard. You only need to paste at the desired location.
cat ~/.ssh/id_rsa.pub | pbcopy
If you only have your private key available, you can generate the public key from it:
ssh-keygen -y
or
ssh-keygen -y -f path/to/private_key
In UBUNTU +18.04
ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
And After that Just Copy And Paste
cat ~/.ssh/id_rsa.pub
or
cat ~/.ssh/id_dsa.pub
Just to give a new perspective to that question, if you use github, you could find your public key at: https://github.com/${USERNAME}.keys
id_rsa.pub is not a directory so you can not use cd to open it.
instead you can use the command cd ~/.ssh to access the folder containing your keys, then use cat id_rsa.pub, nano id_rsa.pub or gedit id_rsa.pub to access the key file.
I use Git Bash for my Windows.
$ eval $(ssh-agent -s) //activates the connection
$ ssh-add ~/.ssh/id_rsa //adds the identity
$ clip < ~/.ssh/id_rsa.pub //THIS IS THE IMPORTANT ONE. This adds your key to your clipboard. Go back to GitHub and just paste it in, and voilá! You should be good to go.
On Mac/unix and Windows:
ssh-keygen then follow the prompts. It will ask you for a name to the file (say you call it pubkey, for example).
Right away, you should have your key fingerprint and your key's randomart image visible to you.
Then just use your favourite text editor and enter command vim pubkey.pub and it (your ssh-rsa key) should be there.
Replace vim with emacs or whatever other editor you have/prefer.
ssh-add is used to show the public key.
man ssh-add
-L Lists public key parameters of all identities currently repre‐
sented by the agent.
On my Linux system I copy it using xclip
ssh-add -L | xclip