cqcn1991 cqcn1991 - 2 months ago 252
Linux Question

Error: Can't open display: (null) when using Xclip to copy ssh public key

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 (like
yum
)

xclip -sel clip < ~/.ssh/id_rsa.pub

# Copies the contents of the id_rsa.pub file to your clipboard


But after I run
xclip -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

Answer

DISPLAY=:0 xclip -sel clip < ~/.ssh/id_rsa.pub didn't work for me (ubuntu 14.04), but you can use :

cat ~/.ssh/id_rsa.pub

to get your public key