uog logo
School of Physics and Astronomy – computing
phas it logo

Contents

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:

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.