SSH and X11 Forwarding

Let me first give you a small bit of background information about both SSH and X-Window to help explain what I will show you later.

Secure SHell (SSH)

SSH is a very common way for users to remotely administer servers and other remote machines and gain shell access. It is more secure method than the previous similar protocol Telnet, as it encrypts all its traffic whereas Telnet does not.

It is arranged in a Server-Client configuration, in which users need to connect from their computer using a ssh-client software to a remote machine that has a ssh-server installed on it.

OpenSSH is by far the most common ssh-server as it has version available for nearly all Linux distro, Mac OSX and Windows. OpenSSH is also the ssh-server I use on my Ubuntu server.

There are a whole host of ssh-clients for all platforms. A decent client for Windows is Putty and is what I use when working in Windows. Most Linux distros and Mac OSX allow you to connect over ssh via the command line using the following command:

ssh “user”@“IP Address”

As this a command line program there are obvious lots of extra options that can be added to the command such as the ability to forward X11 to the clients machine, more on that later. The latter being a setting configured by the ssh-server

In order to connect to a remote machine you will need to have both a local account and that account must also have access rights to connect remotely

X-Window system

Quite simply the X-Windows system is the most fundamental part of the graphical display that actually underpins nearly all Linux GUI’s and window managers*. Without the X-Windows system running you would not have any GUI display.

The current implementation of this is known as X11. Mac OSX has built in support for displaying X11 using its preinstalled X11 application environment. However Windows system do not have native support for X11 so suitable X11 program needs to be installed in order for X11 programs to be forwarded and displayed properly. Unfortunately I don’t really use this feature much on Windows so I have not tested any of the available software and hence cannot recommend any either.

*Note due to large number Linux distros there is a very real chance than some might not use the X-Windows system and instead use a completely different system for their GUI and window managers.

So hopefully now you have a basic understanding of both SSH and X11. As I mentioned before you can forward X11 over SSH using the following command

ssh -X “user”@“ip-address”

You will then be prompted to enter your password.

Then simply run what ever applications you like, for example Nautilus, from the command line using the following:

nautilus&

Notice the & at the end of the command, this allows the program to run unattached to the terminal so that you can continue to use the command line to issue further commands without first having to exit the running X11 program, hence it gives you the ability to run multiple X11 programs at once.

There are a whole host of X11 specific programs designed for simplicity and to increase performance.

You can install all the X11 applications using the following command:

sudo apt-get install x11-apps

A page describing the contents of this package can be found here.

One thing I have found is that your connection can be refused by the server if you change users whilst still using the original connection. If you need to run a command with root privileges you can append sudo at the start of the command. Another method would be to simply open another connection as the Root user and run all your critical commands there instead.

Below is a collection of screen snippets I took of Ubuntu applications I forwarded over SSH.


Finally here is a side by side comparison of how Transmission being run natively on a Ubuntu desktop and using X11 over SSH:
Transmission-X11-v-Gnome_1