[x11] How can I specify a display?

When I run some programs over SSH, such as firefox &, I get an error

Error: no display specified 

I would like to open many displays, still showing the stdout of each program.

Initial Question: How can I specify the display to get a many-displayed program?

Pablo Santa Cruz gives me the following code as a solution. I do not understand it.

$ export DISPLAY=yourmachine.yourdomain.com:0.0

$ firefox &

What are yourmachine and yourdomain.com in the command?

This question is related to x11

The answer is


When you are connecting to another machine over SSH, you can enable X-Forwarding in SSH, so that X windows are forwarded encrypted through the SSH tunnel back to your machine. You can enable X forwarding by appending -X to the ssh command line or setting ForwardX11 yes in your SSH config file.

To check if the X-Forwarding was set up successfully (the server might not allow it), just try if echo $DISPLAY outputs something like localhost:10.0.


Try

export DISPLAY=localhost:0.0

$ export DISPLAY=yourmachine.yourdomain.com:0.0
$ firefox &

login to your server via

ssh -X root@yourIP

edit /etc/ssh/sshd_config file, and add this line to it.

X11UseLocalhost no

Restart sshd. for CentOS (check your distribution)

/sbin/service sshd restart

check your DISPLAY

echo $DISPLAY

you should see this

yourIP:10.0

Enjoy

firefox

for more info


Even i faced the same in CentOS 6.8.

yum reinstall xorg*

End your current session and open another session in tool like mobiXterm. Make sure session has X11 forwarding enabled in the tool.


I faced similar problem today. So, here's a simple solution: While doing SSH to the machine, just add Ctrl - Y.

ssh user@ip_address -Y

After login, type firefox &. And you are good to go.


I through vnc to understand the X11 more. To specify the display to get a many-displayed program, export DISPLAY=IP:DisplayNum.ScreenNum

For example,

vncserver :2
vncserver -list
echo '$DISPLAY'=$DISPLAY 
export DISPLAY=:2  # export DISPLAY=IP:DisplayNum or export DISPLAY=:DisplayNum for localhost; So that can vnc connect and see the vnc desktop :2 if $DISPLAY is not :2.
echo '$DISPLAY'=$DISPLAY

Try installing the xorg-x11-xauth package.


I ran into a similar issue, so maybe this answer will help someone.

The reason for the Error: no display specified error is that Firefox is being launched, but there is no X server (GUI) running on the remote host. You can use X11 forwarding to run Firefox on the remote host, but display it on your local host. On Mac OS X, you will need to download XQuartz in order to use X11 forwarding. Without it, you won't have a $DISPLAY variable set, so if you try and echo $DISPLAY, it will be blank.


Please do NOT try to set $DISPLAY manually when connecting over SSH.
If you connect via SSH -X and $DISPLAY stays empty, this usually means that no encrypted channel could be established.

Most likely you are missing the package xauth or xorg-x11-xauth. Try to install it on the remote machine using:

sudo apt-get install xauth

or

sudo apt-get install xorg-x11-xauth

After that end and restart your SSH connection. Don't forget to use SSH -X so that X Window output is forwarded to your local machine.

Now try echo $DISPLAYagain to see if $DISPLAY has been set automatically by the SSH demon. It should show you a line with an IP address and a port.