VirtualBox + Ubuntu + SSH + x11

My hands got itchy today, so I thought of having Unix available remotely, since I do almost everything remotely. I had an old version of VirtualBox (1.6 I think) installed on one of my (remote) Windows box, so I downloaded an Ubuntu 8.10 image and threw it in as a guest. It installed perfectly, and had immediate network access, but the guest additions wouldn’t work. At first it appeared to be a privilege problem, so I went to Terminal and ran the following:

cd /media/cdrom
sudo ./

and it failed with an Xorg can’t be installed error. So I pulled the new VirtualBox 2.1.2 and did the same thing, this time it passed without a glitch. The additions are like “drivers” for the VirtualBox “hardware”, giving the guest a larger screen resolution than 800×600.

SSH was a breeze too, with this line:

sudo apt-get install openssh-server

Now problem 2 was getting the Guest machine to accept incoming connections. And this guy gave the best solution for me:

> cd \Program Files\Sun\xVM VirtualBox
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort 22
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort 22
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol TCP

This sets up port forwarding such that incoming connections on port 22 on my Windows host will go into the Ubuntu guest, which hosts the SSH server. All was good, after a VM restart and I could PuTTY in smoothly.

Next, problem 3. I had Xming installed, but wasn’t very sure how to use it. I had hoped it wouldn’t be difficult to use or configure. Fortunately, Wikipedia had a nice link to a video tutorial for my exact situation.

The steps:

  1. Install Xming with Portable PuTTY. Make sure the Xming server is started.
  2. On the Intrepid guest, edit /etc/ssh/sshd_config, search and make sure “X11Forwarding yes” is uncommented. For my case this was already forwarded by default, so I didn’t even bother to restart my sshd.
  3. Fire up your PuTTY, go to the SSH > X11 tab, Enable X11 forwarding and specify “localhost:0” as the X display location. Connect to the Ubuntu guest.
  4. Start up a GUI application, such as “gedit &”.

In X11, the client is the Unix machine, and the server is the display where the GUI will appear.

Now I have what I wanted, it was fun, I hope some point in time I’d need such a configuration. Probably when I need quick Unix access for testing. Otherwise it’ll be for helping to answer other people’s Unix questions!

Leave a Reply