Ubuntu Remote Desktop Guide

So, I had a little mishap with my fileserver last week – the motherboard died on it and the primary hard drive I use for my OS died as well. So, its finally back up and running, and I figured I’d re-write my TightVNC Server Guide since Ubuntu now has the ability to use VNC built right into the desktop. I’m going to be writing this guide as if I don’t have physical access to the box since that is actually the case.

First off, I installed the server version without a GUI, so I had to install the ubuntu-desktop package:

SSH into the machine you’re going to be working on and issue the following command:

$ sudo apt-get install ubuntu-desktop

After about half an hour of downloading and installing packages, in theory you should have the gnome-desktop installed. Now, your best bet to actually get it started is to actually reboot the machine remotely.

$ sudo shutdown -r now

Once the system comes back up you will need to enable X-Forwarding on it, SSH back in and edit the following files:

$ sudo vim /etc/ssh/ssh_config

Make sure the following three lines are under the “Host *” section:

ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

Save the file, and then edit sshd_config:

$ sudo vim /etc/ssh/sshd_config

Add (or uncomment):

X11Forwarding yes

Save the file and restart ssh, don’t worry this won’t kill your current terminal sessions.

$ sudo /etc/init.d/ssh restart

Now, open whatever X11 Application you have – on my Macbook its X11, you should get a terminal in whatever app you use.

Use the following command to SSH into your server:

$ ssh -X -C [email protected]

Once you’ve logged in, you will be able to start a gnome session using the following command:

$ gnome-session

Give it a few minutes to fully load up the desktop (depending on your connection speed). Once you have the desktop loaded, you should have the standard toolbar across the top. You’ll want to click System->Preferences->Remote Desktop. This will bring up the remote desktop preferences pane pictured below. In this pane you will want to allow other users to view the desktop, allow other users to control your desktop, make sure ask you for confirmation is unchecked and add a password. When you’re done the screen should look like below:

Now you’ll want to enable automatic login:

Click System->Administration->Login Window
Click on the Security tab and check off Enable Automatic Login and select your user account. Also check off Enable Timed Login and select your account. I couldn’t get a screenshot of this as of writing since my X-Forwarding got a little messed up and I had to do some roundabout stuff to actually get to this window.

Now you’re done with the configuration – reboot the system.

Once the server comes back up, you’ll be able to tell if you did everything correctly by issuing the following:

$ netstat -anp | grep 5900
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::5900                 :::*                    LISTEN      6507/vino-server

Note that it is listening on port 5900. Now open your favorite VNC client and connect to Display 0, and you’ll be at the same desktop as your server is.