4

I am having troubles to start x11vnc service on Ubuntu server 16.04 Gnome. It used to work just fine under 14.04. Not sure if related to x11vnc itself or the systemd.

Here is the systemd service file :

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared -o /var/log/x11vnc.log

[Install]
WantedBy=multi-user.target

The /etc/x11vnc.pass is present and has been generated using x11vnc -storepasswd /etc/x11vnc.passwd

After reboot, x11vnc is started, but no luck to connect to it with vnc, and the x11vnc.log files says :

03/05/2017 16:12:19 passing arg to libvncserver: -rfbauth
03/05/2017 16:12:19 passing arg to libvncserver: /etc/x11vnc.pass
03/05/2017 16:12:19 passing arg to libvncserver: -rfbport
03/05/2017 16:12:19 passing arg to libvncserver: 5900
03/05/2017 16:12:19 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 30259
xauth:  unable to generate an authority file name
03/05/2017 16:12:19 -auth guess: failed for display='unset'
03/05/2017 16:12:19 -auth guess: since we are root, retrying with FD_XDM=1
03/05/2017 16:12:19 -auth guess: failed for display='unset'

To validate that x11vnc works fine, I simply manually run on the server :

x11vnc -rfbauth /etc/x11vnc.passwd

and with that I can successfully connect with vnc. But how can I start it automatically ?

M-Jack
  • 1,326
  • 2
  • 11
  • 15
  • How did you run this before on 14.04? – Mark Stosberg May 03 '17 at 19:44
  • instead of using systemd, the vnc server was started with upstart : `start on login-session-start script /usr/bin/x11vnc -xkb -env FD_XDM=1 -auth guess -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.passwd -forever -bg -rfbport 5900 -o /var/log/x11vnc.log end script` – M-Jack May 03 '17 at 20:43
  • 1
    @M-Jack Did you ever solve this? I'm running into the same issue on 18.04 – Scott Willeke Jul 07 '18 at 15:53
  • @ScottWilleke with 18.04, I've came out with the following solution (in very brief) : first replace GDM with LightDM `apt install slick-greeter` because GDM does not start on the same Display as the user session, then disable Wayland, see /etc/gdm3/custom.conf – M-Jack Aug 01 '18 at 13:18

1 Answers1

0

It sounds like your Upstart script ran when a user logged in. It would then have access environment variables related to the login and be running as a user.

The systemd translation you have runs as root in the background, not in the context of a login session.

If you want this to start when a particular user logins, considering using the Ubuntu Unity autostart feature instead.

In my experience, systemd is not well-suited for starting user applications during a graphical login process.

Mark Stosberg
  • 3,771
  • 23
  • 27
  • 2
    I am using Gnome and not Unity, so no autostart here. Also I'd like to start x11vnc even if no user is logged in, so when gdm has started. – M-Jack May 04 '17 at 12:06