SSH and XWindows
If you want to be able to start an application which displays an X window (aka X11), then you will have to have an X server running on your local machine (ie, your laptop or your other off-campus machine). You may need to install further software to do this.
Getting started §
Linux
(or other non-macOS unixes): this is built-in, unless you have a deliberately very minimal install
macOS
macOS: Apple recommends the XQuartz distribution. After you have installed this (you need to log out and log in again after installation), you can ssh to a remote machine, as described below, and start an X application, whereupon its windows will automatically be thrown back to your Mac (ie, just like on a Linux box).
Windows
Windows: There are multiple ssh and X-server programs for Windows. But if you're using WSL (and multiple people suggest that you should be), then this should Just Work in a Linux-like way, though perhaps see WSLg for some further advice.
If, however, you need to do it by hand, in some sense, then:
-
Main recommendation: MobaXterm is a commercial but free-to-use X Server for Windows. It is distributed as a single application, which makes it easy to install and start.
-
The standard suggestion here is Putty. This works dependably, and has some functions that MobaXterm doesn't, but has a rather less smooth experience than MobaXterm. Chapter 2 of the putty documentation gives detailed instructions on how to use that to connect – the ‘host name’ is as above, and the ‘protocol’ is
SSH
. -
XMing is a standalone X11 windows server for (MS) Windows.
-
Some people swear by Cygwin, which is ‘a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows’, and which includes an X Server. Cygwin has more functionality than XMing or MobaXterm: these may be useful, but are probably overkill if X services are all you want.
Connecting §
Once you have your X server running locally, you can connect to the
remote machine with the -X
option (or whichever option in your
client application enables ‘X11 forwarding’). This ‘forwards’ the X11
connection from the remote machine to your local one:
home% ssh -X myname@foo.physics.gla.ac.uk
Password: xxxxxxxx
[...]
You can verify that this is working correctly by giving the command
foo.physics% echo $DISPLAY
localhost:10.0
foo.physics% xclock&
foo.physics%
If all is working correctly,
the $DISPLAY
environment variable will be set,
and have a value which is localhost
followed by a low-ish
number. The xclock
program should display a clock on your local
machine, and this is thus an end-to-end test of this functionality
(maybe: these days, xclock
is sometimes not installed by default, in
which case try xterm
instead).
If you are logging in via the login bastion machines, rather than
using the VPN, you will at this point want to ssh onwards to the
actual target machine. In this case you should again give the -X
option.
Terminology: servers? and clients? §
Terminological curiosity: in the world of X Windows, the terms ‘server’ and ‘client’ at first appear to be the wrong way round: the X ‘server’ is the application on your local machine, which provides graphics services to the ‘client’ program running on the remote machine. Until you realise this, X Windows explanations can seem incomprehensibly back-to-front.