I’m following in Generating SSH Keys, it says
sudo apt-get install xclip
# Downloads and installs xclip. If you don't have
apt-get
, you might need to use another installer (likeyum
)xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
But after I runxclip -sel clip < ~/.ssh/id_rsa.pub
I get Error: Can't open display: (null)
What is the problem? I googled around but found nothing about it
Based on the date of this question the original poster wouldn't have been using Windows Subsystem for Linux. But if you are, and you get the same error, the following alternative works:
Thanks to this page for pointing out Windows' clip.exe (and you have to type the ".exe") can be run from the bash shell.
The following is also working for me:
add by user root this command : ssh user_to_acces@hostName -X
user_to_acces = user hostName = hostname machine
Have read the documentation you've linked. That's totally silly!
xclip
is just a clipboard. You'll find other ways to copy paste the key... (I'm sure)If you aren't working from inside a graphical X session you need to pass the
$DISPLAY
environment var to the command. Run it like this:Of course
:0
depends on the display you are using. If you have a typical desktop machine it is likely that it is:0
This was too good of an answer not to post it here. It's from a Gilles, a fellow user from askubuntu:
DISPLAY=:0 xclip -sel clip < ~/.ssh/id_rsa.pub
didn't work for me (ubuntu 14.04
), but you can use :to get your public key