Tunneling X over SSH on Ubuntu 9.10

“Just a second”, you’re thinking, “I thought this blog was supposed to be about Oracle stuff ?”
This is true…broadly speaking. However, I’ve spent a fair chunk of the last week playing with Ubuntu 9.10 server working up to putting Oracle on it. This particular mini-adventure will come in handy when I come to do the actual install as Oracle uses a graphical interface as it’s main installation tool.

So, this tuneling X over SSH sounds pretty impressive. Tuneling itself sounds very technical, a fact augmented by the inclusion of a TLA in the phrase. And the X just serves to make it sound rather mysterious and exciting.

As is so often the case in such matters, the truth is rather more prosaic.

Tunneling X over SSH is simply a technique for allowing graphical apps on one machine to run under the Window Manager of another whilst connected via SSH.
Why would you want to do this ? Well, not being a Linux expert, I have listened to the advice that, generally speaking, Windows Managers are not installed on servers as they take up resources that could more usefully be allocated to other things ( like Oracle databases, to take a random example).

You don’t buy that ? OK, you’ve got me – the truth is I initially tried to install openbox, couldn’t get it to work, so went with this. What follows is an account of all of the steps I took to get this working. Some of these may well be unnecessary, but I’ve included them just in case. I’ll be sure to point out where I think I may have gone up a blind alley. I hope that you, dear reader, will also be able to help me see the error of my ways !

One other point to note – this is a server I’m messing around with at home. In more formal environments, I’m sure that you’d be rather more concerned with ensuring that adequate security was implemented in terms of which users have permissions to run X ( or ssh, come to that).

First stop was the ever-informative Ubuntu Community Documentation, specifically, the bit about installing a GUI on the Server.

Getting the packages

All of the following packages and configuration changes take place on the server.

Get the X11 packages for a “minimal” server installation

sudo apt-get install xserver-xorg xserver-xorg-core 

Next step was to try getting things working by using openbox

sudo apt-get install openbox 

NOTE – This is the bit where I fiddled around with openbox for a bit, but couldn’t get it to work.
I’ve not removed the package so can’t say for certain that it’s not required, but I’m fairly sure that this is the case.

It was at this point that I turned to the idea of tuneling.
I already had two of the required X11 packages, so I only had to download :

sudo apt-get install X11-apps
sudo apt-get install x11-xserver-utils

X11-apps contains useful little apps that you can run to confirm everything is working as expected.

The next step is to uncomment the allow forwarding parameter in /etc/ssh/sshconfig and set it to yes

sudo vi /etc/ssh/ssh_config

In the file, change the line
#ForwardX11 no
ForwardX11 yes

To Test

On the client, open a Terminal session and initiate an X windows session via ssh :

ssh -X username@server

Note the switch in the command is uppercase X, not lowercase x.This is relevant because both are valid switches for the ssh command.

The first time you connect using the X switch as each user, a file called .Xauthority will be created in that user’s home directory. This will facilitate subsequent X-windows connections by the user.

Once you’re in type


You should see a clock face display on the client machine.
Congratulations – it’s all up and running. And for my next trick…I’ll be running the Oracle Installer via this method. Wish me luck !


4 thoughts on “Tunneling X over SSH on Ubuntu 9.10

  1. Pingback: Good disk use visualization for a Linux VPS? Drija

  2. Excellent! I just started using Xming a day ago when a sysadmin friend of mine told me how to start using it. Imagine my excitement that I could now open graphical programs from our headless server on my laptop!

    I was trying to get it working on an Ubuntu laptop and found your article in the search. It gave me the clues I needed. All I had to do was change the file in /etc/ssh as you did to get it working.

    What is the difference between that option and the trusted option? What are the apps that come with it and what can they be used to do?

    Thanks again for a great article!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.