I spent a couple of evenings on this, and it's getting a bit frustrating since I managed to had it working on my previous Ubuntu (MANY years ago).

I'd like to have an vnc server running on my server at any time (including login screen) to remotely connect and login. Not a different session: share the same session I would see on the physical display of my server and log on to it remotely via VNC in a private network (aka home).

I understand it's a combination of XDMCP, GDM3, initd and VNC configurations, but I don't have enough experience to tune the various howtos I found online to work for ubuntu 18.04.

These seems promising links: https://lists.debian.org/debian-user/2017/04/msg00529.html https://codeghar.wordpress.com/2009/06/11/remote-login-with-gdm-and-vnc-on-fedora-11/ https://wiki.openindiana.org/oi/4.7+Remote+Graphical+Login:+Using+Xvnc+and+gdm+for+One-Shot+sessions

Right now (in case anyone else is going crazy like me), I installed nomachine and it took the grand total of 2 minutes to setup and it works as I wanted (including iOS clients!): https://www.nomachine.com/ ---bittersweet ¯_(ツ)_/¯

  • Need to bind x11vnc to screen instead of session. – Seb Jun 6 at 8:51
  • Thank you for the NoMachine rec. After a weekend of installing x11vnc, tightvnc, tigervnc, vnc4server and more and nothing working with 18.04 and gdm3, I finally gave up and used NoMachine, worked perfectly. Pretty disappointed in 18.04 LTS right now though. – jb510 Aug 12 at 18:09

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 /lib/systemd/system/x11vnc.service

# Description: Custom Service Unit file
# File: /lib/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
Restart-sec=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) I believe it is possible to install a fake monitor driver and bind x11vnc to that.

Side notes

  1. Incase you are using virt-manager (which also enables VNC on 127.0.0.1:5900) you may want to bind x11vnc to your LAN IP (-listen 10.0.0.1)
  2. The parameters used to start x11vnc tell it not to ask for an additional password (-nopw)
  • 1
    To start vnc session x11vnc -display :0 It can only connect to one session, once your session is expired or closed, you will have to start again with x11vnc -display :0 – ashish Aug 30 at 5:58

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.