Post categories

Recommended Wordpress Hosting from WPEngine

  • I use these guys for some of my clients; absolutely rock solid and blazingly fast - check them out!

Here are a couple of ads whose clicks and views help me pay for my server hosting

VNC from boot on Ubuntu 10.04 all the way to 14.04 without logging in, using LightDM (or GDM) and x11vnc (includes LUbuntu with lxdm and Linux Mint LMDE with mdm)

In LUbuntu (and Ubuntu and XUbuntu) there are a number of fairly decent VNC servers, broadly split into 2 groups – 1 lot that let you view the existing desktop (i.e. remote control your existing session) and the other lot that create seperate X sessions that only exist under the VNC server. I’m interested in the first lot, and I’d like to be able to login to my X session over VNC before I’ve logged in on the box itself.

A standard package in Ubuntu is the Vino VNC server – it’s the one that’s used when you select “allow users to remotely control my pc” which is quite handy. However, it only lets you log in once your user has logged into Gnome or XFCE (i.e. after you’ve got past the login promt in GDM or LightDM) – so if your PC reboots whilst you’re away, it’s a bit of a pain as you can’t VNC into it.

In XUbuntu 11.10, the team removed GDM (Gnome Display Manager) and replaced it with LightDM (Light Display Manager) so these instructions are specific to that, although they may work on other setups. These instructions also carry over to Ubuntu/LUbuntu (lxde-based) 12.04, and probably 12.10 too as they now all use the same login display manager.


LightDM apparently supports a VNC server out of the box; however, it’s designed to work with tightvncserver (or similar) which create separate X sessions (the 2nd lot of VNC servers I mentioned above) so not quite what we’re after1.

Ubuntu derivatives use Upstart ( to manage startup processes – LightDM (and GDM!) creates a login-session-start event when the display manager is up (i.e. when X is all loaded, but before you’ve logged in) so we’ll create an upstart job that listens for that, and starts a VNC server on the existing X session, allowing connections before login.

Step 1 – we want the VNC server to have a password, just in case – the VNC port shouldn’t really be exposed to the outside world – it’s easy to wrap it in an SSH connection to encrypt everything for you (see here for a good explanation of how to set that up).

sudo x11vnc -storepasswd /etc/x11vnc.pass

This will prompt you for a password to (lightly) secure your VNC server.

Step 2a (for LightDM – XUbuntu, and all Ubuntu variants 12.04 onwards) – create the upstart job. Put this in /etc/init/x11vnc.conf :

start on login-session-start
/usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log
end script
Note: if you’d like this to work with GDM instead, you’ll need to find where GDM puts its MIT-MAGIC-COOKIE – I believe it’s /var/run/gdm/auth... or something similar, although I haven’t got a box to test it on

Step 2b (for lxdm – LUbuntu) – LXDM doesn’t seem to emit the right event, but instead is has /etc/lxdm/LoginReady which lets you specify pre-login events. However, we need to first get the xauth setup properly. Edit /etc/lxdm/lxdm.conf and uncomment the line:


This specifies that we’re going to use a different xauth path; we also need to update the /etc/lxdm/LoginReady file with our x11 command, using the updated xauth path.

Put this in /etc/lxdm/LoginReady:

/usr/bin/x11vnc -xkb -auth /tmp/.Xauth1000 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log

Step 2c (for mdm – Mint LMDE)
Mint LMDE (Debian edition) doesn’t use the upstart things; instead, put this at the end of /etc/mdm/Init/Default:

/usr/bin/x11vnc -xkb -auth /var/lib/mdm/:0.Xauth -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log

Note that this uses the auth path for mdm which is /var/lib/mdm/:0.Xauth
Step 3 – Done!

Reboot! That’s all there is to it – hopefully, you’ll now have a shared VNC server which connects to your main desktop X session, running on port 5900 using the password you gave, all started automatically as soon as LightDM asks you to login. Hooray!

Note for Ubuntu 14.04+ users

The default screen-locker in recent Ubuntu versions is light-locker; this is usually activated when your screensaver kicks in or your desktop is locked. For some reason, this has a bizarre behaviour that replaces the DISPLAY your desktop is running on, and this causes x11vnc to then fail to interact with your active session.

If you’re happy to use xscreensaver instead (which is, in my opinion is just as powerful and secure), then you can use that as a replacement for light-locker, and this doesn’t replace the active DISPLAY, meaning x11vnc continues to work. To do this:

sudo apt-get purge light-locker
sudo apt-get install xscreensaver

Then reboot, and no more ridiculous disconnections.

1. If you’d like to have a separated VNC server running too you can – make sure you have tightvncserver installed (or similar) and then put

port=5901 # I've used port 5901 so it doesn't interfere with the setup from above

in your /etc/lightdm/lightdm.conf  then reboot – should have a separate X session available for VNC’ing into.