Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have a server running Ubuntu 12.10 and need to be able to remote to this server without being logged-in.

I have found many solutions, but none seem to work with 12.10.

Can anyone give me step-by-step instructions on how to configure x11vnc to start as a service (prior to user login) so that when connecting with VNC I will be presented with a graphical login screen?

I'm new to Linux so please give as much detail as possible in your responses/comments.


share|improve this question

4 Answers 4

Install x11vnc:

sudo apt-get install x11vnc

Create a password for your user:

x11vnc -storepasswd

If you have ssh setup you can use it to start x11vnc assuming you are logged in already, but remember to tell it to use your password file:

x11vnc -usepw

If you are not logged in you will get an error with the explanation:

If NO ONE is logged into an X session yet, but there is a greeter login
program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
to find and use the raw display manager MIT-MAGIC-COOKIE file.
Some examples for various display managers:

 gdm:     -auth /var/gdm/:0.Xauth
          -auth /var/lib/gdm/:0.Xauth
 kdm:     -auth /var/lib/kdm/A:0-crWk72
          -auth /var/run/xauth/A:0-crWk72
 xdm:     -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
 dtlogin: -auth /var/dt/A:0-UgaaXa

Assuming you are using lightdm for the login you can fix this problem you can start x11vnc with the command:

sudo x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw

I am not sure this is the best idea to run x11vnc as root. Maybe someone could edit with a way to access the login without using sudo.

Once this is running you should be able to connect using a vnc client such as krdc (for KDE). You might want to use GNU Screen to keep x11vnc running without needing the ssh session open

I was able to figure this out using

Here is a sample upstart job you can use to make it run at startup. It needs to be put in /etc/init/x11vnc.conf:

# description "start and stop x11vnc"

description "x11vnc"

start on runlevel [2345]
stop on runlevel [^2345]

console log
#chdir /home/
#setuid 1000
#setgid 1000

respawn limit 20 5

exec x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth /var/run/lightdm/root/:0 -usepw

Once you have made this file you can start it by running: sudo start x11vnc You can check the log at: /var/log/upstart/x11vnc.log

share|improve this answer
You can run x11vnc as a normal user, no problem. For example: ssh to the host and run x11vnc -safer -forever -display :0 2>&1 & in a tmux session (good practice), it'll run under $USER. – Terry Wang Jul 17 '13 at 5:43
Also, just for reference, in order to change the viewport:… – Wtower Dec 19 '14 at 9:25
This doesn't explain how to have it auto start as requested (and is a common requirement for such a feature) – LovesTha Feb 25 at 21:39
@LovesTha I second that. I've been trying to get x11vnc to autostart, but nothing I've tried works. Have you had any luck with this? – linuxgringo Jun 21 at 14:09
I did, but I can't remember how and I've blown away the config I had it working on. – LovesTha Jul 14 at 4:58

Here's how:

  1. Install the X11VNC server (or through Ubuntu Software Center -> X11VNC Server)

    sudo apt-get x11vnc
  2. Create a VNC password file.

    sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
  3. Create a job file in the editor nano (or gedit, leafpad etc.).

    sudo nano /etc/init/x11vnc.conf
  4. Paste this into the file:

    start on login-session-start
    /usr/bin/x11vnc -xkb -forever -auth /var/run/lightdm/root/:0 -display :0 -rfbauth /etc/x11vnc.pass -rfbport 5900 -bg -o /var/log/x11vnc.log
    end script
  5. Save the file. You created a job for the Upstart event login-session-start.

  6. Restart Ubuntu.

That's it! You should now be able to connect with any VNC client even before login.

share|improve this answer
But how do you get it to work when lightdm doesn't create the auth file till a monitor is connected? – LovesTha Feb 25 at 21:37
@didibus I've been trying to do this in Lubuntu, but x11vnc fails to autostart every time. It won't even start as a service, for that matter. File syntax is correct and I can start x11vnc from the shell just fine. What am I missing? – linuxgringo Jun 21 at 14:10

The above answers solve the problem, though a couple of amendments for versions of Ubuntu with systemd (15.04+), as follows:

  • Take advantage of new -auth guess functionality in x11vnc - which helps!
  • Update for systemd (not upstart)

Run the following to install:

sudo apt-get install x11vnc
sudo x11vnc -storepasswd yourVNCpasswordHERE /etc/x11vnc.pass
sudo nano /lib/systemd/system/x11vnc.service

Insert this into the file:


ExecStart=/usr/bin/x11vnc -xkb -noxrecord -noxfixes -noxdamage -display :0 -auth guess -rfbauth /etc/x11vnc.pass
ExecStop=/usr/bin/killall x11vnc


Then, start with:

sudo systemctl daemon-reload
sudo systemctl start x11vnc

And ensure the service starts on boot:

sudo systemctl enable x11vnc
share|improve this answer
Referenced for some advice on Requires/Afters params – babelmonk Sep 22 at 9:48

Please have a look at this, it is already asked.

share|improve this answer
This is a link only answer. It is better to answer the question properly, and then give the link as a reference or accreditation. – fabricator4 Dec 17 '12 at 19:02
The link above only configures VNC to be started at the time a user logs-in, which is a problem since you have to be logged-in before you can login with VNC. I want VNC to start prior to this so that onces I'm connected, I can login as any user. – user115250 Dec 17 '12 at 19:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.