Ubuntu 17.04 – Configure X11VNC Server to Boot at Startup

Hello World, 

If you are following us since a long time, you probably know that when it comes to perform remote desktop connections to an Ubuntu machine, we tend to use XRDP software solution.  A new version of xRDP software has been released in December 2016 which include a backend server component to the solution (i.e. the xorgxrdp piece of software). With xRDP version 0.9.xx, you should not need to install any VNC Server components as the xrdp package provide the necessary backend server component to perform the remote connection.  

This is all fine when everything is working as expected.  Based on our recent experience with xRDP and Ubuntu 17.04, it seems clear that for certain scenario/situations, VNC Server can still be used as a fallback solution if xRDP is not behaving as expected. 


Googling around about Ubuntu 16.04 and later,  it seems that having a VNC server software installed and configured properly on Ubuntu machines is really difficult.  After some investigations, it seems that the expected results relies mainly in the VNC server choice.  In this post, we will quickly cover the installation and configuration of the X11VNC server as VNC Server. 

X11VNC server  – The best Option

Installing the x11vnc software

Again, if you have been following us for a long time, you probably know that we have used x11vnc serve a lot in the past.  This was the vnc server package used to perform custom installation of xrdp software on Ubuntu machines.   This is our preferred VNC Server solution. 

The software can be installed quite quickly and easily. Moreover, once installed, there is no special configuration needed to have it working against Unity.  To install the x11vnc component, you simply issue the following command. 

sudo apt-get install x11vnc -y


Click on Picture for Better Resolution

Manually start the x11vnc service

After having installed the software, you simply need to ensure that the vncserver is started.  To have the vnc server listening to request, issue the following command from the Terminal 



Click on Picture for Better Resolution

At this stage, the machine is listening to the port specified by the user.  If you look at your terminal console, you will see the information about which port to connect to while performing the remote connect


Click on Picture for Better Resolution

So with this information, it’s time to open your favourite VNC Client, provide the ip address and the port retrieved from the x11vnc command and access the remote desktop.


Click on Picture for Better Resolution


Click on Picture for Better Resolution

To provide a little bit more protection, it’s usually recommended to protect the remote desktop access through a password usage. To configure your x11vnc to request password when connecting through the vnc protocol, the following command should be executed

x11vnc -storepasswd

Set the password and confirm it.  When requested to save the password into the file, ensure that you select yes.


Click on Picture for Better Resolution

In order to configure the vnc server to request and check password defined above, the following command needs to be executed

x11vnc -rfbauth  ~/.vnc/x11pass.vnc


Click on Picture for Better Resolution

When performing the connection from the vnc client, you will need first to provide connection information (ip address and port) and you wil also be prompted for a password.   


Click on Picture for Better Resolution


Click on Picture for Better Resolution

 At this stage, the desktop should be displayed to you and you can start working on your system remotely


Click on Picture for Better Resolution

So far, we have seen that’s possible to use x11vnc server software to connect remotely to a Unity Desktop against Ubuntu 17.04 in a flawless way…

Automatically start the x11vnc service

The major drawback of the solution described above is that a user needs to be logged into the machine. Moreover, the x11vnc server needs to be started manually.  If none of these conditions are met, there will be no way to perform a remote connection through the vnc protocol. So, to have a workable VNC software solution, there is a need to configure the x11vnc server service  available at the boot time.

Luckily for us (and for you), the instructions to have the x11vnc server started at boot up time have been already provided in one of our previous posts.  As a bonus, there is also a script that can be used to perform the configuration automatically for you…

To make the x11vnc server service start automatically at boot up on an Ubuntu 17.04 system, perform the following actions

  • Downloads the vnc-startup.sh script from this location
  • Extract the content of the zip file. You should end up with a single file called vnc-startup.sh
  • make the vnc-startup.sh file executable by right-clicking on it, go to permissions tab, and select the option “allow executing files as a program”

Click on Picture for Better Resolution

  • Open a Terminal application and execute the script by issuing the following command sudo ./vnc-startup.sh. You might get prompted for a password

Click on Picture for Better Resolution

  •  The script will then ask you to specify which password should be used when connecting to VNC Server, you will be requested to confirm this password.  Finally, the script will ask you if you want to save the password into a file, ensure that you select yes

Click on Picture for Better Resolution

  • The system will reboot automatically.  At this stage, the vnc server should be running and should be ready to accept vnc connection.  Using your favourite vnc client, try to connect to your Ubuntu device (while nobody is logged into the system) and if everything is working as expected, you should see the login screen page displayed through your vnc viewer client 

Click on Picture for Better Resolution

We did it ! we have configured our Ubuntu machine to accept vnc connections when no one is logged on and the vnc server service is starting automatically at boot process

Final Notes

Voila ! This recipe seems to still work in Ubuntu 17.04 and Unity Desktop.  We have been playing around with other vnc software (i.e vino-server and tigervnc). However, x11vnc server is the best option because it connect to the native desktop and you can configured it easily to boot at startup…. 

Hope you enjoyed this one…. 

Till next time 

See ya


22 thoughts on “Ubuntu 17.04 – Configure X11VNC Server to Boot at Startup

  1. Is there an easy way to change the screen resolution of the client VNC session? I am using Chicken and I could not see a way to get a bigger screen?


  2. @Ian,

    we do not use chicken vnc client…so I could not tell you how to increase resolution….

    Till next time
    See ya

  3. This is about as easy a setup of vnc on Linux as I’ve ever seen, including the little script to make it run at startup.

    One thing I had to change to get it to work though –

    When you run this command: x11vnc -storepasswd, it asks to save the file under /home/user/.vnc/passwd.

    The next line, you wrote:
    “In order to configure the vnc server to request and check password defined above, the following command needs to be executed: x11vnc -rfbauth ~/.vnc/x11pass.vnc”

    If I use that “x11pass.vnc” filename, it won’t work. But if I give it the exact filename from the previous command, just “passwd”, it works perfectly.

    You may want to try it yourself and change that filename.

    Otherwise, it works awesome, thanks for the article!


  4. Trying to get this going on 16.04.02. Works when started manually, but not from systemd. I get this over and over in syslog:
    — x11vnc loop: 460 —
    — x11vnc loop: waiting for: 23385
    18/09/2017 15:02:56 passing arg to libvncserver: -rfbauth
    18/09/2017 15:02:56 passing arg to libvncserver: /etc/x11vnc.pass
    18/09/2017 15:02:56 passing arg to libvncserver: -rfbport
    18/09/2017 15:02:56 passing arg to libvncserver: 5900
    18/09/2017 15:02:56 x11vnc version: 0.9.13 lastmod: 2011-08-10 pid: 23385
    xauth: unable to generate an authority file name
    18/09/2017 15:02:56 -auth guess: failed for display=’unset’
    18/09/2017 15:02:56 -auth guess: since we are root, retrying with FD_XDM=1
    18/09/2017 15:02:56 -auth guess: failed for display=’unset’
    — x11vnc loop: sleeping 2000 ms —

    Any thoughts?

    Thanks for taking the time to put all this together

  5. @Ryan;

    We assume that you have use our vncstartup.sh script…If this is the case, you should first check that the vnc password file is created accordingly and it can be used as well by executing the command in a terminal console (as a normal user)…

    If this is working, you should be good to go…

    Hope this help
    till next time
    See ya

  6. Was REALLY hoping this would work, as I’ve spent hours trying to get VNC working on Ubuntu 17.04, but when I ran vnc-startup.sh I got “Failed to enable…???…directory does not exist”, and the machine rebooted before I could make a note of the full message. Why is life soooooo difficult with Ubuntu??

  7. @Ian,

    To be able to provide help, we would need to have the full error message.. You have two options.. Either you try to perform a manual installation following the steps as described in the post (so not using the script) and see where you get the error or you can run the script but you have to comment the last line so the machine will not reboot and you can see exactly the error message…

    When you have the error message, you can try to debug or share this info with us and we can see what the problem could be

    Hope this help
    Till next time
    See ya

  8. So I’ve followed all the steps and the computer rebooted.
    It loaded back to the login screen and I thought “Great! Here we go!”
    Tried to access the machine via VNC on my Win10 machine and it failed.
    Is there something wrong with the way I followed your instructions?

  9. @Erick,
    I do not know how you performed the installation (so I cannot tell you if something went wrong)
    Specify which Ubuntu version you are using and the Desktop environment (we assume ubuntu 17.04 with Unity Desktop, so please confirm)
    Can you manually start the vnc service and see if you can access it ?
    Have you check the logs ?
    Have you checked the /etc/X11/Xwrapper.config ?
    Cannot help with some basic information
    Hope this help
    Till next time
    See ya

  10. I’ve got basically the same error as Ryan on 17.10.
    I’ve disabled Wayland and I can get VNC to run if I execute the command when logged in and on a terminal, but it doesn’t seem to work automatically after restarting the server before or after I’ve logged in.
    It only seems to work when I run it from Terminal?
    Any ideas?

  11. @Eddy,
    It’s seems to work for us and the x11vnc service survive to reboots… I would assume that you have followed all the necessary steps described in the post…
    Have you tried to restart the service (using systemctl restart x11vnc and then systemctl status x11vnc) -> do you see any errors there ?
    are you sure that no errors or typo in the unit file
    are you sure that x11vnc.pass file exists and readable ?

    Hope this help
    Till next time
    see ya

  12. Hi
    Thanks for the reply.
    It’s running and I see the error xauth: unable to generate authority.
    The referenced password file does exist and if I run the same x11vnc command with the same argument specified from a console once logged in it works fine. It just doesn’t work automatically.
    I’m guessing it’s some sort of permissions problem with the authorisation settings, but I don’t know how to go about fixing it.
    Any idea what I can try?

  13. Hi

    What is the reason for a very very very slow vnc connection if I turn of the Monitor. With a connected Monitor
    the connection ist very well

    Thank you

  14. @Pascal,

    I have no direct clue about this….When using X11vnc in headless mode (no monitor), you need to perform some additional configurations. You might need to install dummy device drivers for the non existing monitor..
    this is just a guess…. Give it a try and share your experience back

    hope this help
    Till next time
    See ya

  15. I use the startup script from you and it has configured successfully.
    But the problem is, once i enter password before entering desktop (ubuntu16), the session will terminated immediately. Same happens while using screen, after i enter the password, the screen will be blacked out for 1 seconds and back to the login prompt

  16. @Jeff;

    Euh…unclear no clue….
    So, if you are using Ubuntu 16.04, you should check the script and procedure to be used with Ubuntu 16.04 (check this post http://c-nergy.be/blog/?p=8984)
    If this is not working, can you have a look at the logs or try to start the x11vnc command manually and see which kind of error you might receive

    Hope this help
    Till next time
    See ya

  17. @Torsten,

    Danke 🙂
    Thanks for the visit and positive comments…. always cool to see that our work can be used by someone else
    Till next time
    See ya

  18. @Griffin,

    Thank you for the very informative post. I tried following your setup (But my host server running x11vnc is Kali instead)
    When i try to connect to the machine using vnc , I get the error “The connection was refused by the computer”

    and also in the syslogs i see the error message
    xauth: unable to generate a authority filename

Leave a Reply