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 or cat ~/.ssh/id_ed25519.pub
You can list all the public keys you have by doing:
$ ls ~/.ssh/*.pub
type command. Or just open the .pub file in notepad and paste it to github.cat ~/.ssh/id_rsa.pubid_rsa.pub, not *.*id_rsa.pubCopy the key to your clipboard and paste it in your preferred location.
$ 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.
check: Generating SSH Keys.
sudo apt-get install xclip -y for those users who doesn't have pbcopy working.sudo apt-get install -y xclip followed by alias pbcopy="xclip -sel clip" and then pbcopy < ~/.ssh/id_rsa.pub OR simply xclip -selection clipboard < ~/.ssh/id_rsa.pubYou 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.
~/.ssh/.ssh-add -L is by far the better option as not every SSH key is an RSA key sitting in the ~/.ssh folder. I much prefer to use my PGP key for authentication and so I do not have a ~/.ssh/id_rsa.pub file at all.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 "[email protected]" -b 4096 It is very simple. After you generated ssh key on your computer, you can access your public ssh key by following command
cat ~/.ssh/id_rsa.pub You should see output similar to the following:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyVGaw1PuEl98f4/7Kq3O9ZIvDw2OFOSXAFVqilSFNkHlefm1iMtPeqsIBp2t9cbGUf55xNDULz/bD/4BCV43yZ5lh0cUYuXALg9NI29ui7PEGReXjSpNwUD6ceN/78YOK41KAcecq+SS0bJ4b4amKZIJG3JWmDKljtv1dmSBCrTmEAQaOorxqGGBYmZS7NQumRe4lav5r6wOs8OACMANE1ejkeZsGFzJFNqvr5DuHdDL5FAudW23me3BDmrM9ifUzzjl1Jwku3bnRaCcjaxH8oTumt1a00mWci/1qUlaVFft085yvVq7KZbF2OPPbl+erDW91+EZ2FgEi+v1/CSJ5 your_username@hostname Also note that the public key begins with ssh-rsa and ends with your_username@hostname.
If you are using Windows PowerShell, the easiest way is to:
cat ~/.ssh/id_<key-type-here>.pub | clip That will copy the key to your clipboard for easy pasting.
So, in my instance, I use ed25519 since RSA is now fairly hackable:
cat ~/.ssh/id_ed25519.pub | clip Because I find myself doing this a lot, I created a function and set a simple alias I could remember in my PowerShell profile (learn more about PowerShell profiles here. Just add this to your Microsoft.PowerShell_profile.ps1:
function Copy-SSHKey { Get-Content ~/.ssh/id_ed25519.pub | clip } Set_Alias -Name sshkey -Value Copy-SSHKey Then, in a PowerShell console, run . $profile to load the functions. Then from now on all you will need to do is run sshkey, and then paste the key into wherever you need via the clipboard.
Open your id_dsa.pub or some_name.pub file with gedit and copy-paste the contents!
Just use:
~/.ssh$ gedit some_name.pub In UBUNTU +18.04
ssh-keygen -o -t rsa -b 4096 -C "[email protected]" 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
On a Mac, you can do this to copy it to your clipboard (like cmd + c shortcut)
cat ~/Desktop/ded.html | pbcopy
pbcopy < ~/.ssh/id_rsa.pub
and to paste pbpaste > ~Documents/id_rsa.txt
or, use cmd + v shorcut to paste it somewhere else.
~/.ssh is the same path as /Users/macbook-username/.ssh
You can use Print work directory: pwd command on terminal to get the path to your current directory.
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 ssh-add, could you provide more specifics that would make your Answer more unique? It may otherwise get flagged as a duplicate answer (not a bad thing, just a tidy up process in stackoverflow). Having said that I would suggest checking all existing answers for any overlap in your thinking in the future. Happy StackOverflowing!
pbcopy < ~/.ssh/id_rsa.pubworked for me! Check this GitHub article