How do 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 and, but no luck. How can I access my SSH public key?

8/8/2018 6:20:37 PM

Accepted Answer

cat ~/.ssh/ or cat ~/.ssh/

You can list all the public keys you have by doing:

$ ls ~/.ssh/*.pub

7/18/2014 8:43:07 PM

Copy the key to your clipboard.

$ pbcopy < ~/.ssh/
# Copies the contents of the 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.


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.


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

notepad ~/.ssh/  

If you're on OS X, use:

pbcopy < ~/.ssh/

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 < (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.


After you generate your SSH key you can do:

cat .ssh/ |pbcopy

which will copy your ssh key into your clipboard.