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 id_rsa.pub
and id_rsa.pub
, but no luck. How can I access my SSH public key?
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.
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/id_rsa.pub
If you're on OS X, use:
pbcopy < ~/.ssh/id_rsa.pub
Here's how I found mine on OS X:
- Open a terminal
- (You are in the home directory)
cd .ssh
(a hidden directory) - 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.