How do I fix a "cannot open display" error when opening an X program after ssh'ing with X11 forwarding enabled?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Secret Catacombs
--
Chapters
00:00 How Do I Fix A &Quot;Cannot Open Display&Quot; Error When Opening An X Program After Ssh'Ing Wit
01:21 Accepted Answer Score 69
01:44 Answer 2 Score 100
02:45 Answer 3 Score 30
03:12 Answer 4 Score 18
03:19 Thank you
--
Full question
https://superuser.com/questions/310197/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#ssh #display #xorg #gtk
#avk47
ANSWER 1
Score 100
From xhost+ : How to Fix “Cannot Open Display” Error While Launching GUI on Remote Server:
Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.
Allow clients to connect from any host using xhost+
Execute the following command to disable the access control, by which you can allow clients to connect from any host.
$ xhost +
access control disabled, clients can connect from any host
Enable X11 forwarding
While doing ssh use the option -X to enable X11 forwarding.
$ ssh username@hostname -X
Enable trusted X11 forwarding, by using the -Y option,
$ ssh username@hostname -Y
Open GUI applications in that host
After opening ssh connection to the remote host as explained above, you can open any GUI application which will open it without any issue.
If you still get the “cannot open display” error, set the DISPLAY variable as shown below.
$ export DISPLAY='IP:0.0'
Note: IP is the local workstation’s IP where you want the GUI application to be displayed.
ACCEPTED ANSWER
Score 69
Check the server's sshd_config
(normally /etc/ssh/sshd_config
), and make sure X11Forwarding
option is enabled with the line
X11Forwarding yes
If X11Forwarding is not specified, the default is no
on the Debian machines I have available to check.
ANSWER 3
Score 30
I've had this problem when logging into a Ubuntu VM from Mac OS X as well -- it doesn't seem to like 'localhost' in the display variable for some reason. So set the IP manually, as harrymc suggests:
export DISPLAY="127.0.0.1:10.0"
Then X11 programs should be fine. It doesn't seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.
ANSWER 4
Score 18
I had this problem with my CentOS KVM server, I was missing the "xauth" program.