failed to open the x11 display : unable to connect

alrightgame picture alrightgame · Jan 26, 2013 · Viewed 23.3k times · Source

The server that supports the graphical display is different from the server I'm sshed into. When I try to open virtualbox, I get this message.

$ Failed to open the X11 display!  

When I try to startx, I get three error messages.

$ PAM authentication failed, cannot start X server

$ giving up.
$ xinit:  No such file or directory (errno 2):  unable to connect to X server
$ xinit:  No such process (errno 3):  Server error.

I don't know where the display variable is, as I'm very new to linux. Any straightforward advice and help would be appreciated.

Answer

Edu picture Edu · Jan 26, 2013

Give option -X on command line to enable X11 forwarding (graphical interfaces).

ssh -X user@hostname

It can be also enabled per host basis by setting "ForwardX11" to "yes" in configuration file (~/.ssh/config). Support for X11 forwarding needs to be also enabled in the target server's sshd configuration file (/etc/ssh/sshd_config) with option X11Forwarding yes.

You should also know that there are some security implications in enabling the X11 forwarding. Read more from ssh and sshd man pages or here. If you control both server and client and trust both equally, there shouldn't be any problem in enabling the forwarding.