Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I believe the benefit of X11 is that it can use the existing desktop but the other ones have you install another desktop, I'm not 100%, but X11 def gave me trouble and others didn't, but X11 worked well when I got it working.

There is currently a bug/glitch w/ Ubuntu/GDM & X11 that requires a hack of Two SystemD files to configure a VNC Server for the Login Screen on Ubuntu and another for the regular desktop. Once any user has logged into the desktop once, the "Login Screen" VNC Server is no longer needed. It is purely for setups where you want to remotely reboot server and connect via VNC (Crazy idea right!)

Here it is:

cat << 'EOF' >~/x11vnc_apt_setup.sh
#!/bin/bash
#Run Script As Root
#Two Service Files due to X11/GDM3 Bug/Workaround
#https://askubuntu.com/a/1036507/395258

UNAME=

apt update
apt-get install -y x11vnc xserver-xorg-video-dummy net-tools
sudo -H -u $UNAME bash -c 'x11vnc -storepasswd'

cat << EOL >/lib/systemd/system/x11vnc.service
[Unit]
Description=VNC Server for X11
Requires=display-manager.service network-online.target multi-user.target
After=multi-user.target

[Service]
User=$UNAME
ExecStart=/usr/bin/x11vnc -display :1 -auth guess -geometry 1366x768 -forever -loop -noxdamage -repeat -rfbauth /home/$UNAME/.vnc/passwd -rfbport 5900 -shared -forever -o /home/$UNAME/.vnc/x11vnc.log
ExecStop=/usr/bin/x11vnc -R stop
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target
EOL

cat << EOL >/lib/systemd/system/x11vnc-login.service
[Unit]
Description=VNC Server for X11 Login Service
Requires=display-manager.service network-online.target multi-user.target
After=multi-user.target

[Service]
User=root
ExecStart=/usr/bin/x11vnc -auth /run/user/120/gdm/Xauthority -forever -loop -noxdamage -repeat -rfbauth /home/$UNAME/.vnc/passwd -rfbport 5901 -shared -forever -o /home/$UNAME/.vnc/x11vnc-login.log -display :0
ExecStop=/usr/bin/x11vnc -R stop
Restart=no

[Install]
WantedBy=multi-user.target
EOL

systemctl daemon-reload
systemctl enable x11vnc x11vnc

EOF
chmod +x ~/x11vnc_apt_setup.sh
cat ~/x11vnc_apt_setup.sh
~/x11vnc_apt_setup.sh
  • No labels