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.






89 responses to “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)”

  1. Thomsa Avatar

    Thank you very much. That’s perfect.

    1. Seb Avatar

      Glad you found it useful 🙂

  2. Ben S. Avatar
    Ben S.

    Thanks for this, worked for me on Xubuntu 12.04 and stayed working after in-place upgrade to 12.10.

    I did notice that it seems to disable X auto-repeat while a VNC client is connected, even on the local side. Adding -repeat to the x11vnc line of the script(s) seems to fix it, or you can run ‘xset r on’ in a terminal to enable it on a case-by-case basis.

    I’m not yet seeing ill effects from omitting -noxrecord -noxfixes -noxdamage and enabling -repeat with TightVNC 2.6 as the client.

    1. Seb Avatar

      Cool, glad it still works on Xubuntu with their display manager.

      The noxdamage makes vnc work when compiz is enabled, and noxfixes will stop a segfault when logging into the desktop when x11vnc is still running…

      But thanks for pointing out the -repeat option; might update the post with it 🙂

      1. Ben S. Avatar
        Ben S.

        According to the Ubuntu x11vnc man pages (, versions shipped with 10.04 LTS and newer will wait until a window manager is running before using XFIXES in order to prevent the crash you mention. It therefore seems safe (so far) to omit the option, which is great for me because I prefer to be able to see what the mouse cursor is actually supposed to look like.

        Since Xubuntu uses xfwm4 instead of compiz by default, it seems safe to omit -noxdamage.

        1. Seb Avatar

          Nice find! Ok I’ll give that a go too 🙂 thank you!

  3. DS Avatar

    Thank you! It works on Ubuntu 12.10

    1. Seb Avatar

      Great! Glad it helped

  4. Chintan Avatar

    I have Ubuntu 12.10 running, I have installed x11vnc and I created the /etc/x11.conf file with the script above but how do you get x11vnc to run on startup? When I do a ps -ef | grep x11 it’s not running.

    1. Seb Avatar

      Do you know which display manager you’re running? You may be able to check the logs for whichever one you’re using (e.g. if you’re running gdm, there are logs in /var/log/gdm that may offer some help)

  5. Jimmy Avatar

    Hi and thanks,
    Your script worked for me fantastic until now 🙁
    no problems at all until :
    I’ve just installed a second vnc server (vnc4server) on 5901
    and my problems started with it:
    I have no problem with connection to vnc4server at 5901 to separate x session (lxdm) but when I try to connect to x11vnc at 5900 I getting a login screen (lightdm) and after typing my password connection is reset (vnc client exits) and I am back to login screen with next connection try. I have removed vnc4server but problem still exist even after restart, so I cant connect anymore to x11vnc.
    I have ubuntu 12.10 minimal with lightdm, lxdm and xbmc
    I need both vnc to main and separate x sessions any help please.

    (there was no autostart for vnc4server made yet)

    1. Seb Avatar

      Have you checked the logs for each of the services? There may be something that might help pinpoint the issue in /var/log/lxdm or /var/log/Xorg.*.log

  6. raytro Avatar

    Thanks for this solution. I spend many hours before I found this. Know it simply works!



    1. Seb Avatar

      Excellent! Glad you found it useful 🙂

  7. Don Z Avatar
    Don Z


    Thanks for the “how to”. I have spent several days trying to get this to work from lubuntu to both lubuntu and ubuntu 12.04 with limited success.

    I tried your instructions and it worked the first time.

    One minor issue – when I used remmina, I got what appeared to be a remote desktop without the bottom panel (only one on default lubuntu).

    After some minor headscratching, I saw the (almost invisible) vertical scroll bar. The bottom panel was off screen! Used the Scale Desktop option to map screen resolutions and all worked fine.

    Again, many thanks.

    Don Z

    1. Seb Avatar

      I’ve not used Remmina so haven’t had this issue; tend to use tight vncviewer or realvnc viewer… but glad the rest worked for you 🙂

  8. Steve Avatar

    FANTASTIC! Works perfect! Your extra instructions for Mint filled in the gaps.


    1. Seb Avatar

      You’re more than welcome! Happy to help 🙂

  9. HaLLoWeD Avatar

    I would like to thank you as well. Tried so many things specially with vnc4server for my xubuntu 12.10 and this page is somehow a headshot worked perfect. Thanks for the article

    1. Seb Avatar

      Excellent! Glad it worked for you 🙂

  10. […] setup a VNC client and optionally setup autologin. In my case I installed x11vnc and followed these directions to get x11vnc server running. In […]

  11. Martín Avatar

    This is absolutely brilliant. Thanks a lot for putting up this guide! I tried this on a MK802 II running Miniand’s Lubuntu 12.04 and it works like a charm.

    1. Seb Avatar

      Glad it helped 🙂

  12. John Avatar

    Guide worked great but..
    Did anyone else try to print the webpage and end up with a giant raptor overlay?

    The exact section I needed ended up being covered by a dinosaur image, goddammit easter eggs

    It scared me to say the least…

    1. Seb Avatar

      Hahaha the raptor shouldn’t actually be shown on the print page.. my bad! However, try pressing:
      up up down down left right left right b a
      That should give you a proper raptor!

  13. Joe Avatar

    Any tips on how to get this on another display? ( :1 )

    1. Seb Avatar

      Hi Joe, I haven’t tried getting it on another display – although perhaps changing the :0 in the auth file to :1 might work? Sorry I can’t be of more help!

  14. Garry Avatar

    This works great on Asus Transformer TF300T tablet and Xubuntu 12.10. Thank you for the easy steps to set this up.

    1. Seb Avatar

      Hooray! Glad it worked for you 🙂

  15. Rick Avatar

    This worked great for me (Ubuntu 12.04, using step 2a for the xubuntu/xfcs desktop environment).

    After the setup, I had to do one more thing that was not documented here: while in the SSH session where I set all of this up, I ran “initcfg start x11vnc” to start VNC for the first time; now, it appears to reliably survive both reboots and logoffs.


    1. Seb Avatar

      Excellent, glad it worked for you 🙂

  16. Andrew Avatar

    Thanks! This is working very nicely on 12.10. Your explanation is great.

    1. Seb Avatar

      Hooray! Glad it all went smoothly

  17. Jose Avatar

    This works perfect with Ubuntu 12.04, but with Ubuntu 13.04 I have problems:
    Ask the password but close inmediately. Do you know how it can work well with ubuntu 13.04?.


    1. Seb Avatar

      I’ve been following my instructions from above on Ubuntu 13.04 and it works fine; which part asks for the password?

      1. Jose Avatar

        Thank you for your answer. Your answer gave me an idea:
        The problem may be for the vnc client.

        Always I use remmina to connect and then I have the problem (in /var/log/x11vnc.log):

        15/10/2013 09:15:08 Using tight encoding for client
        15/10/2013 09:15:08 client useCopyRect: -1
        15/10/2013 09:15:08 client_set_net: 0.0354
        15/10/2013 09:15:08 rfbSendUpdateBuf: write: Connection reset by peer
        *** rfbSendFramebufferUpdate *FAILED* #1
        *** fb_push ublen not zero: 3934
        15/10/2013 09:15:08 copy_tiles: allocating first_line at size 41
        15/10/2013 09:15:08 client_count: 0
        15/10/2013 09:15:08 Restored X server key autorepeat to: 1

        But if I use another vnc-client, for example vinagre, i can connect ok.

        So the problem is in remmina as vnc-client to connect with Ubuntu 13.04.

        Thank you very much.

        1. Seb Avatar

          How bizarre! Sometimes, I use the RealVNC plugin in Chrome just because it’s so convenient: and that seems to work fine too 🙂

  18. Bernd Avatar

    Recent Lubuntu distros have LightDM too. So the step 2a worked great for me under Lubuntu 13.10.

    1. Seb Avatar

      Wonderful! Glad it worked for you

  19. HenkS Avatar

    Very good tutorial! This works like a charm:). Thank you.

    1. Seb Avatar

      Great! Glad it worked for you 🙂

  20. Paulo Avatar

    is Step 2c required?
    I did not find the specified file

    1. Seb Avatar

      Step 2c is only required if you couldn’t do 2a or 2b – which variant of ubuntu are you using?

  21. Michael McIntyre Avatar
    Michael McIntyre

    I am running Ubuntu 14.04. I followed all of the steps in this guide, but when I connect it seems like it is in View-Only mode. I am using RealVNC on a Windows 8.1 machine. I have the options selected to allow keyboard and mouse input, but no luck. I can only view the screen. I can’t interact with any windows or type text. Any thoughts?

    1. Michael McIntyre Avatar
      Michael McIntyre

      Never mind. I rebooted again and this time it started working.

      1. Seb Avatar

        Great! Glad it worked for you

  22. Wayne Avatar

    Thanks this worked perfectly

    1. Seb Avatar

      Great! Glad it helped

  23. HunterZ Avatar

    If you remove the -bg parameter, upstart will track the x11vnc process for you. This allows you to (re)start/stop the x11vnc server via initctl commands (e.g. sudo initctl start/restart/stop x11vnc). It may also be worth putting the respawn keyword after the “start on” line if you’re at all paranoid about x11vnc crashing, as this will direct upstart to relaunch it when it dies.

    Here’s the set of parameters that I’m currently testing:
    /usr/bin/x11vnc \
    -xkb \
    -auth /var/run/lightdm/root/:0 \
    -nowireframe \
    -wirecopyrect top \
    -wmdt xfce \
    -threads \
    -repeat \
    -rfbauth /etc/x11vnc.pass \
    -shared \
    -forever \
    -rfbport 5900 \
    -o /var/log/x11vnc.log

    1. HunterZ Avatar

      Forgot to mention that the “-wmdt xfce” line is only for Xubuntu/Xfce.

      1. Seb Avatar

        Hmm looks interesting, will take a look; thanks for the feedback 🙂

  24. Bekir Avatar

    This worked great for Ubuntu 14.04LTS!! Thank you!

    1. Seb Avatar

      Great! Glad to hear it’s still working on recent releases

  25. Ballsies Avatar

    Another Happy Customer!
    Thanks for this — worked first time and is exactly what I needed for a VNC connection to my desktop at home, from my android running pocketcloud.

    1. Seb Avatar

      Keep ’em coming! That’s the same setup I use 🙂

  26. Poul Grønlund Avatar
    Poul Grønlund

    Thanks man, really helpful

    1. Seb Avatar

      You’re welcome! Glad you found it useful

  27. keshara dorakumbura Avatar
    keshara dorakumbura

    This is great.!!! Many thanks for all the works you done, 🙂

    NOTE: I tested this on Ubuntu 1004 which uses GDM. So as the article says, the location of MIT-MAGIC-COOKIE stored at,

    last part of “x” varies each time a user logs into the system. So what i did was set is as below;

    It works….

    1. Seb Avatar

      Hooray! Thanks for the feedback

  28. […] Neulich habe ich selbst erst ein Setup aufgesetzt, bei dem ich über x11vnc + SSH-Tunnel + lightdm einen Linux-Desktop für einen SSH-Nutzer freigegeben habe. Für die Referenzen: Basierte auf diesem HowTo. […]

  29. Eyup Avatar

    Thank you very much, very well done …

    1. Seb Avatar

      You are very welcome.

  30. Rocker Avatar

    For Lubunut 10.04 I tried to edit the file /etc/lightdm/lightdm.conf in this way and work.

    display-setup-script=/usr/bin/x11vnc -auth /var/run/lightdm/root/:0 -rfbauth /etc/x11vnc.pass -xkb -noxrecord -noxfixes -noxdamage -forever -bg -rfbport 5900

    1. Seb Avatar

      Brilliant! Great to hear you got it working even on a very old release!

  31. dbp Avatar

    For Lubuntu 14.04 LTS + LightDM, sometimes this does not work due to the default screen may switch from :0 to :1 or :2 etc and during screen saver / screen lock and for some reason unable to release it.

    To kill the wrong screen (cannot login VNC, or after login it is black screen), run below command:

    killall lxsession

    To check which is active screen (:0 or :1 or :2 etc), run below command:

    who -u | grep -v grep | sed -e “s/ \+/ /g” | cut -d” ” -f 2 | grep “^:”

    To automate this change in script, you need to replace the :0 as a variable in /etc/init/x11vnc.conf, which may not be possible. As a result, a script run in /etc/rc.local may help:

    # This script will (re)attach VNC to the running X11 session


    while (true); do {
    display=`who -u | grep “^guest-” | grep -v grep | sed -e “s/ \+/ /g” | cut -d” ” -f 2`
    if [ “$display” == “” ]; then {
    display=`who -u | grep -v grep | sed -e “s/ \+/ /g” | cut -d” ” -f 2 | grep “^:”`
    if [ “$display” == “” ]; then {
    display=`ps ax | grep “/usr/bin/X ” | grep -v grep | cut -d”X” -f 2 | cut -d” ” -f 3`
    }; fi
    }; fi
    if [ ! “$display” == “” ]; then {
    echo “Switch to display $display …”
    killall x11vnc > /dev/null 2>&1
    killall -9 x11vnc > /dev/null 2>&1
    x11vnc -display $display -noxfixes -listen localhost -no6 -rfbauth ~/.x11vncpasswd -auth $vtpath/$display > /dev/null 2>&1
    }; fi
    sleep 5
    }; done

    1. Seb Avatar

      That is certainly one way to handle it.

      The issue is actually caused by light-locker which is what the default Ubuntu screensaver uses to lock your screen, and it’s this that does the bizarre DISPLAY replacement. However, I’m more than happy using xscreensaver or i3lock, and they don’t replace the active DISPLAY which means x11vnc continues to work.

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

      Then reboot, and no more ridiculous disconnections.

      (I’ve put this in the main article, thanks for reminding me!)

  32. Alfonso Avatar

    Wow, it works even on Lubuntu 14.04.1 / PPC (I had no success with other methods). I just needed steps 1, 2a and 3, without any extra quirks.

    1. Seb Avatar

      Fantastic! Hooray for using portable linux packages 🙂

  33. […] is the block-screen: the default package (for this task) has recently changed to light-locker. It turns out that, as a side-effect, light-locker switches current VT to (I guess) VT8 (where default Xorg/X11 […]

  34. Ron Avatar

    This worked great on 14.04 with steps 1, 2a, and 3

    (just don’t forget to disable Vino if you had it turned on)

    Question: What is the correct way to switch users with this method? I noticed that by selecting the setting icon in the top right hand corner of the screen and then selecting one of my other desktop users that i lose connection.

  35. […] 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. […]

  36. Phil Avatar

    It works!!! I use Lubuntu I could get a x11vnc server working but I had to use autologin…. I upgraded from Lubuntu 11.10 to 14.10 …. my vnc server would just stop after 5 minutes and not do anything…. This just works.

  37. Nickko Avatar

    I’m trying Lubuntu 15.04 who use SystemD by default instead upstart.

    Since 2 day, I’m triyng to get the same behaveiour than you with upstart (with Lubuntu 14.10 (upstart), I haven’t any problem).

    Can you help me ?

  38. David Froger Avatar
    David Froger

    Thanks a lot for this howto! I’m trying to set up kodi at home, and it helps me a lot. The introduction about the 2 groups of VNC server and the instructions for all the different display manager are very usefull. Thanks again.

  39. Lubo Avatar

    Just trying this with Lubuntu 14.04.

    Seems the path to /etc/lxdm/lxdm.conf has changed. For Lubuntu 14.04 that “file” is a symbolic link to /etc/alternatives/lxdm.conf so I edited the original file instead.

  40. Lubo Avatar

    An important correction to my last comment, and hopefully something you can add/correct in the original post as well:

    I undid the steps in my last comment and followed step 2a instead, it seems my Lubuntu 14.04 uses lightdm (by default as far as I know), so step 2a in your post worked.

    Maybe add a cautionary note before step 2a to verify which dm is active before attempting 2a,b,c? By looking in /var/log for a file directory named gdm, lightdm, or *dm?

  41. cmcanulty Avatar

    OMG I have been struggling with vnc issues and xubuntu 14.04 for over a year. Steps 1 and 2a fixed it! I spent so much time googling for answers and never suspected it was a ldm issue. I support 15 xubuntus at our local library and need to get in fast to any machine to give remote help and support. I am still having issues with the ssh tunneling I have to go through a router on the remote end and a forwarded port. I keep getting password failed. I think it is some step required to set a ssh password but can find nothing on that. Thank you so much I hope this stays with updates.

  42. Ben Gillam Avatar
    Ben Gillam

    Hi, Thanks for the guide got most of it working but it wont start

    I use xubuntu 14.04 lts with all updates run. It appears like its starting but i get

    28/09/2015 15:51:27 x11vnc version: 0.9.13 lastmod: 2011-08-10 pid: 1143
    No protocol specified
    28/09/2015 15:51:27 XOpenDisplay(“:0”) failed.
    28/09/2015 15:51:27 Trying again with XAUTHLOCALHOSTNAME=localhost …
    No protocol specified

    28/09/2015 15:51:27 ***************************************
    28/09/2015 15:51:27 *** XOpenDisplay failed (:0)

    *** x11vnc was unable to open the X DISPLAY: “:0”, it cannot continue.
    *** There may be “Xlib:” error messages above with details about the failure.

    Which suggests X isnt running when it fires up?

    Any ideas how i can trouble shoot this.

    Thanks for any help

  43. Keith Avatar

    Followed these instructions but I fall at the last hurdle. When I try to connect I get an authentication failure. It is as though I typed the password wrong but I’m definitely using the one I created in the password file.

    I’m running Ubuntu 14.04.3 and the only deviation from these instructions have been at the point where I attempted to swap the screensaver with;
    sudo apt-get purge light-locker
    sudo apt-get install xscreensaver

    Both commands failed, the former because it was not installed and the latter because it was already installed.

    I’m now scratching my head and any pointers would be much appreciated.

  44. Peter Avatar

    I’m using Ubuntu 14.04.3. I’m getting to Ubuntu desktop login screen (I have multiple users on this server) and after I enter my password the desktop wallpaper comes up for a short time , but then VNC viewer (both TightVNC and RealVNC) return error message “Connection is gracefully closed”. What this could be/

  45. Jeff Berman Avatar
    Jeff Berman

    Thanks for these instructions! I’ve used them in the past and everything worked perfectly.

    The process has changed, starting with Xubuntu 15.04, however. For anyone interested, these new instructions worked for me with Xubuntu 15.10:

  46. Eric Krause Avatar
    Eric Krause

    I just wanted to point out that this also works with Linux Lite v2.4 using the instructions from step 2a. Just wanted to throw that out there in case any other users are looking for this information.

  47. […] Veja nas referências algumas artimanhas adicionais que dá pra fazer instalando também tk8.4 como por exemplo, manter um tray-icon, permitir ou negar conexões, e avisar com popup sempre que alguém conecta ou desconecta.. Isso pode ser útil pra você. Por: Hudson Murilo dos Santos Referências: […]

Leave a Reply

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