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. 

Overview

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

  Installx11vnc_1

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 

x11vnc

  Installx11vnc_2

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

  Installx11vnc_3

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.

  Installx11vnc_4

Click on Picture for Better Resolution

  Installx11vnc_5

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.

  Installx11vnc_6

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

  Installx11vnc_7

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.   

  Installx11vnc_4

Click on Picture for Better Resolution

  Installx11vnc_8

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

  Installx11vnc_5

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”

X11VNC_UB1701_1

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

X11VNC_UB1701_2

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

X11VNC_UB1701_3

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 

X11VNC_UB1701_4

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

 

5 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?

    Thanks
    Ian

  2. 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!

    -Bryan

  3. 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

  4. @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

Leave a Reply