Your command is right, but the error shows that you didn't create your ssh key yet. To generate new ssh key enter the following command into the terminal.
ssh-keygen
After entering the command then you will be asked to enter file name and passphrase. Normally you don't need to change this. Just press enter. Then your key will be generated in ~/.ssh
directory. After this, you can copy your key by the following command.
pbcopy < ~/.ssh/id_rsa.pub
or
cat .ssh/id_rsa.pub | pbcopy
You can find more about this here ssh.
cat ~/.ssh/id_rsa.pub
then you can copy your ssh key
To copy your public key to the clipboard
cat ~/.ssh/id_rsa.pub | pbcopy
This pipes the output of the file to pbcopy.
With PowerShell on Windows, you can use:
Get-Content ~/.ssh/id_rsa.pub | Set-Clipboard
cat .ssh/id_rsa.pub | bcopy
This works for me.
For using Git bash on Windows:
cat ~/.ssh/id_rsa.pub > /dev/clipboard
(modified from Jupiter St John's post on Coderwall)
Another alternative solution, that is recommended in the github help pages:
pbcopy < ~/.ssh/id_rsa.pub
Should this fail, I recommend using their docs to trouble shoot or generate a new key - if not already done.
Another alternative solution:
cat ~/.ssh/id_rsa.pub | xsel -i -b
From man xsel
:
-i, --input
read standard input into the selection.
-b, --clipboard
operate on the CLIPBOARD selection.
Window:
cat ~/.ssh/id_rsa.pub
Mac OS:
cat ~/.ssh/id_rsa.pub | pbcopy
Does the file ~/.ssh/id_rsa.pub
exist? If not, you need to generate one first:
ssh-keygen -t rsa -C "[email protected]"
Check the path where you have generated the public key. You can also copy the id_rsa
by using this command:
clip < ~/.ssh/id_rsa.pub
Source: Stackoverflow.com