Hi all,

Back from the brink with a few new blog posts. I’ve recently migrated my server from RHEL to Ubuntu – given i dont have an active subscription anymore, and for the ‘home user’ the packages available (repos, to be precise) for Ubuntu are far better than RHEL/Centos.

I made a bit of a booboo in installing Ubuntu 13.10 which installs headless by default – and i do like to have a VNC for that odd occassion you just cant get something working – KVM networking, for example! *Grumble grumble*.

So, what i did – install MATE (Gnome 2, i pine for the good old days), installed VNC, and then configure VNC to use MATE on a new session.

1. Install MATE:

sudo add-apt-repository "deb http://mirror1.mate-desktop.org/ubuntu saucy main"
sudo apt-get update
sudo apt-get --yes --quiet --allow-unauthenticated install mate-archive-keyring
sudo apt-get update
sudo apt-get install mate-core
sudo apt-get install mate-desktop-environment

This installs the MATE desktop, ready for use (note, if you want to convert your server into a desktop you’ll need to install some sort of login/display manager – gdm, for example). I’m only using MATE from a VNC invocation so i dont need that.

2. Install VNC Server

sudo apt-get install vnc4server

This simply installs a VNC server – not much to explain here really!

3. Configure new VNC sessions to use MATE

VNC stores its config file (xstartup) in the “~/.vnc/” folder. Therefore you need to navigate to that directory first:

cd ~/.vnc/

Then you will need to create a new file, or edit one (if its there already) called ‘xstartup’:

nano xstartup 

.. and paste the following into it:

#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
# x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# x-window-manager &
mate-session &
# gnome-session --session=ubuntu-2d &

The key line is ‘mate-session &’ – this tells your VNC server to create a new ‘desktop’ using mate, instead of X, Gnome, or any other desktop you have.

4. Wrap-up

Next, start up a VNC server and open up the firewall:

iptables -I INPUT 3 -s 192.168.0.0/24 -p udp –dport 5900:5904 -j ACCEPT

In my example, i’m going to be running 4 VNC servers – on port 5901, 5902, 5903 and 5904. We can create these 4 sessions using the colon-number approach:

vncserver :1
vncserver :2
vncserver :3
vncserver :4

(Im sure those of you who are of that mindset could do a ‘for i in..’, but im too lazy). 

Finally, get yourself a VNC client, i.e. RealVNC – connect to your server – ipaddress:5901, and voila, your desktop is alive!