I have recently changed from Ubuntu 16.04 LTS to 18.04 LTS, as I needed a newer version of kvm/qemu.
With 16.04 I was able to easily get the x11vnc service (daemon) running by following the instructions from "Community Help Wiki" : https://help.ubuntu.com/community/VNC/Servers
This has a script required to set up the x11vnc daemon service, which lets you log into a machine remotely without having to first be logged in locally. I require this as I have my machine running as server and located in the basement and I always access it via VNC, not locally.
Initially I did nothing with my clean 18.04 install other than adding the systemctl
script exactly as per "Community Help Wiki" instructions: "Have x11vnc start automatically via systemd in any environment (Vivid+)".
On finding that this no longer worked I then did the following based on some searching:
Disabled "Wayland" display manager by editing
/etc/gdm3/custom.conf
and settingWaylandEnable=false
in this script:[daemon] # Uncoment the line below to force the login screen to use Xorg #WaylandEnable=false WaylandEnable=false <--- HERE
Changed the
/lib/systemd/system/x11vnc.service ExecStart
command to use a differentxauth
directive as in 18.04 it appears that there is no automatically generated$HOME/.Xauthority
file which can be found via the-xauth guest
directive:From:
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5900 -shared
To:
ExecStart=/usr/bin/x11vnc -auth /run/user/120/gdm/Xauthority -forever -loop -noxdamage -repeat -rfbauth /home/USERNAME/.vnc/passwd -rfbport 5920 -shared
I did this based on some reading and testing on Xauthority, which indicated that the location of the .Xauthority
token is now given via $XAUTHORITY
environment variable.
To find the value of this I run the following "find
" command to find which processes has an XAUTHORITY
environment variable defined.
NOTE: this uses the linux /proc/<procid>/environ
file structure to search through the process environment variables,
cd /proc
sudo find . -maxdepth 1 -type d -exec sh -c "(test -f '{}'/environ && cat '{}'/environ | tr '\0' '\n' | grep XAUTHORITY= )" \;
This returned two different results:
XAUTHORITY=/run/user/120/gdm/Xauthority
XAUTHORITY=/run/user/1000/gdm/Xauthority
I then used the following to find the corresponding process ids:
sudo find . -maxdepth 1 -type d -exec sh -c "(test -f '{}'/environ && grep -aH XAUTHORITY= '{}'/environ )" \;
The corresponding processes for these are:
240 tty1 Sl+ 0:00 /usr/lib/gnome-session/gnome-session-binary --autostart /usr/share/gdm/greeter/autostart
14923 tty2 Sl+ 0:00 /usr/lib/gnome-session/gnome-session-binary --session=ubuntu
The first of these appears to be associated with the login greeter screen, while the second is the user desktop.
A further check of the environment variables shows that one has USER=gdm
and the other has USER=<ME>
The problems is that if I use the "greeter" auth location, then I get prompted to provide a password which is then followed by black/blank screen. If I use the user auth location, then I do not get any client connection at all as the status returns an error that it is unable to open the Display:
13/05/2018 16:19:14 *** XOpenDisplay failed.
So it seems that you get caught by the change in xauth mechanism.
Can someone please provide some guidance on this?