Advertisement
Advertisement


How do I access my SSH public key?


Question

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?

2018/08/08
1
636
8/8/2018 6:20:37 PM

Accepted Answer

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

2014/07/18
1074
7/18/2014 8:43:07 PM

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 you can paste it wherever you need.

To get a better idea of the whole process, check this: Generating SSH Keys.

2018/08/08

You may try to run the following command to show your RSA fingerprint:

ssh-agent sh -c 'ssh-add; ssh-add -l'

or public key:

ssh-agent sh -c 'ssh-add; ssh-add -L'

If you've the message: 'The agent has no identities.', then you've to generate your RSA key by ssh-keygen first.

2015/03/28

If you're on Windows use the following, select all, and copy from a Notepad window:

notepad ~/.ssh/id_rsa.pub  

If you're on OS X, use:

pbcopy < ~/.ssh/id_rsa.pub
2018/08/08

Here's how I found mine on OS X:

  1. Open a terminal
  2. (You are in the home directory) cd .ssh (a hidden directory)
  3. pbcopy < id_rsa.pub (this copies it to the clipboard)

If that doesn't work, do an ls and see what files are in there with a .pub extension.

2018/08/08

After you generate your SSH key you can do:

cat .ssh/id_rsa.pub |pbcopy

which will copy your ssh key into your clipboard.

2014/01/18

Source: https://stackoverflow.com/questions/3828164
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]