Although server hosts typically have no graphical desktop and only serve console-based clients, these machines still have the ability to serve a GUI display screen to a remote desktop if necessary.
Question: Q: X11 forwarding problem (again) I just got a brand new iMac (OSX 10.14.4) and of course now X11 forwarding is not working anymore even after trying to apply all the 'tricks' that worked with my previous computer.
The X11 protocol makes it possible to send the graphical display to a remote graphical desktop.
I'm running a Ubuntu server in VMWare. And I would like to forward the X11 from the Ubuntu guest to the Mac host. I've installed XQuartz 2.7.9 (xorg-server 1.17.4) on the Mac host. And SSH forwarding on the Ubuntu is enabled. OpenSSH server on Debian 10 supports X11 Forwarding. So, you can not only manage your server remotely via SSH, you can also install a graphical user interface on your server, enable X11 Forwarding and use the graphical applications installed on the server remotely. I tried to SSH into one of the servers that IS working, and then SSH into the problem server from that using Mac's Terminal: ssh -X11 -2 [email protected] # runs some Linux (don't remember which distro) ssh -X11 -2 [email protected] # runs Ubuntu 11.04. Mac X11 Forwarding For forwarding remote X sessions over ssh you can use either Terminal.app (also found in /Applications/Utilities ) or xterm. If you are using the Mac OS X Terminal, you will need to set your DISPLAY variable.
From a production standpoint, this can be useful if applications running in “headless” mode need to be debugged. For example, if Selenium tests using a headless version of Chrome are failing in a server environment, you may get hints by looking at the remote browser visually.
Overview
So that we are clear on terms, the “X client” is the Ubuntu host that is console-based and has no graphical interface of its own. We are going to enable the ssh service of this “X client” to forward X11 communication.
Ssh Forward X11
The “X server” is what is run on the graphic desktop environment. This is either your Ubuntu desktop host, Windows, or Mac. From the desktop “X server” we are going to ssh into the “X client”, making sure that X11 forwarding setting is enabled.
With this X11 communication channel properly established via ssh, a graphical applications run on the “X client” will be tunnel across and displayed on the GUI desktop.
X client, ssh settings
The first thing you have to validate is whether ssh on the X client is configured to forward X11, ensure “/etc/ssh/ssh_config” has the following values.
And then restart the ssh service:
X client, test application
A quick GUI based application we can use for testing is gvim.
Test from Ubuntu graphical desktop
![Forwarding Forwarding](/uploads/1/2/4/3/124378843/645514400.png)
Since you are running from an Ubuntu graphical desktop then you already have an X server running locally so no further installation is necessary.
Establish an ssh connection from your graphical desktop to the remote X client using the “-X” switch for X11 forwarding.
Which will then bring up the graphical vim editor on your desktop.
The DISPLAY variable is set to ‘localhost’ because the ssh connection is tunneling the X11 protocol.
Test from Windows
To test from Windows, we need to install an ssh client capable of X11 forwarding like PuTTY, and an X Server implementation such as VcXsrv. Download and install both applications with all defaults.
Open PuTTY and establish an ssh connection from Windows to the remote X client, making sure you enable X11 forwarding in Connection>SSH>X11. As shown below, check the X11 forwarding box, put in “localhost:0.0” for the display location and select the “MIT-Magic-Cookie” setting.
The DISPLAY variable is set to ‘localhost’ because the ssh connection is tunneling the X11 protocol.
Once you have started the remote ssh connection, run gvim from the console.
And it should be displayed on your Windows desktop like below.
Firefox example
For a more complex example, you can always install something like Firefox. From the X client machine:
And then from the Windows or Ubuntu desktop, create the ssh connection, and run:
REFERENCES
https://gist.github.com/vietlq/8b20d09fdfe5f02f8b511c7847df39ee (example using gvim)
https://www.uxora.com/unix/45-xdisplay-over-ssh-with-putty-xming-vcxsrv (putty settings)
https://www.techotopia.com/index.php/Displaying_Ubuntu_Linux_Applications_Remotely_(X11_Forwarding) (for Ubuntu using ssh -X)
https://sourceforge.net/projects/vcxsrv/ (download VcXsrv)
http://www.geo.mtu.edu/geoschem/docs/putty_install.html (putty and xming)
https://serverfault.com/questions/273847/what-does-warning-untrusted-x11-forwarding-setup-failed-xauth-key-data-not-ge (troubleshooting DISPLAY, xauth)
http://users.stat.umn.edu/~geyer/secure.html (do not use xhost anymore, if using ssh then xauth should work)
If you are connecting to HCC clusters via a PC running Windows, please take the following steps to setup X11 forwarding.
- Download Xming to your local PC and install. Downloadlink: https://downloads.sourceforge.net/project/xming/Xming/6.9.0.31/Xming-6-9-0-31-setup.exe
- Download PuTTY to your local PC and install. Download link: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
- Open Xming and keep it running in the background.
- Configure PuTTY as below:
- To test your X11 setup, after login, type command
xeyes
and pressenter. - Close the xeyes application by “Ctrl + c” from the terminal or clickthe close button on the up-right corner of the graphical window.
If you are connecting to HCC clusters via a Macintosh, please take the following steps to setup X11 forwarding.
![X11 forwarding mac mojave X11 forwarding mac mojave](/uploads/1/2/4/3/124378843/596778607.jpg)
- Check the OS version on your Mac, if it’s below 10.8., you can simply type
ssh -Y username@hostname
in your terminal to login. - If your OS version is newer than 10.8, please do the following:
- Download and install XQuartz.Download link: https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg
- Type
ssh -Y username@hostname
in your terminal to login. - To test your X11 setup, after login, type command “xeyes” and pressenter.
4. Close the xeyes application by “Control + c” from the terminal orclick the close button on the up-left corner of the graphicalwindow.
If you are connecting to HCC clusters via a Linux laptop, please take the following steps to setup X11 forwarding.
- Open the remote client terminal.
- Type
ssh -Y username@hostname
” in your terminal to login. - To test your X11 setup, after login, type command “xeyes” and pressenter.
- Close the xeyes application by “Ctrl + c” from the terminal or clickthe close button on the up-right corner of the graphical window.
Special note about Indirect GLX
If you are using OS X or Linux, you may need to re-enable indirect GLX (IGLX) in order forthe GUI application to run properly. IGLX was disabled for security reasons starting withX.org version 1.17 (Linux) and XQuartz version 2.7.9 (OS X). More information about thischange is available at this link.
To re-enable IGLX, use the follwing instructions:
OS X
X11 Forwarding For Mac Installer
Open a terminal on your Mac, and run the following command:
Log out or restart your Mac for the changes to take effect.
Linux
You will need to create a small Xorg configuration file. This requires
root
access, sorun commands with care.Be extremely cautious running commands as
root
. You can permanently make your system unusable.Create a file at
/etc/X11/xorg.conf.d/iglx.conf
with the following contents:X11 Forwarding Mac To Linux
Restart X11 by logging out, or by rebooting your machine.