ubuntu 20 vnc connect after logout not working

this solution seems correct

https://askubuntu.com/questions/1033274/ubuntu-18-04-connect-to-login-screen-over-vnc

switch the display manager to lightdm, and then bind vnc with x11vnc

Ubuntu 18.04 switched from LightDM to GDM3. Connecting to the login screen with VNC while using GDM3 is currently not possible. The easiest way to get this VNC functionality back is to simply switch back from GDM3 to LightDM.

LightDM is still being actively developed and used by many Linux distributions including some other flavors of Ubuntu. So no worries there.

Install LightDM

apt install lightdm

Should you for some reason come to regret switching to LightDM:

dpkg-reconfigure gdm3

Once you have LightDM installed and configured as your default greeter..

Install x11vnc from packages

apt install x11vnc

Create the file /etc/systemd/system/x11vnc.service

# Description: Custom Service Unit file
# File: /etc/systemd/system/x11vnc.service
[Unit]
Description="x11vnc"
Requires=display-manager.service
After=display-manager.service

[Service]
ExecStart=/usr/bin/x11vnc -loop -nopw -xkb -repeat -noxrecord -noxfixes -noxdamage -forever -rfbport 5900 -display :0 -auth guess
ExecStop=/usr/bin/killall x11vnc
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target

Enable the x11vnc service

 systemctl enable x11vnc.service

This assumes screen :0 represents your monitor and binds x11vnc to that monitor instead of a session. If you do not have a monitor (headless) you can install the xserver-xorg-video-dummy package and use the dummy driver to configure a virtual :0 screen for you.

Previous Post

Leave a Reply