Ssh – How to Run a GUI Application on Remote Server’s X11 Display via SSH

sshx11

In this picture, on my virtual-machine I have Redhat running with an SSH server, and I'm remotely logged-in via SSH. I want to run gedit via SSH but have the gedit window open on the remote Redhat server, not the machine from which I run the SSH client. I don't want to use ssh -X root@192.168.100.195, I want to open gedit on the ssh server's display via ssh client.

enter image description here

Best Answer

Try doing it like this instead:

DISPLAY=:0 gedit

Or even, just:

export DISPLAY=:0

Before you run your commands.

The reason you see Cannot open display: with no display specified after the : is because $DISPLAY is not set, as ssh isn't aware you have an X session running.

You said you don't want to use ssh -X (X11 Forwarding), but in case others end up here, you might also look into using X11 forwarding, if you want the GUI application to display on your local (client) machine rather than the remote (server) machine.

Related Question