0

I am trying to setup TigerVNC - or indeed any VNC server - on Ubuntu 20.04, and I am beginning to get frustrated, because none of the instructions I can find actually work, although I have got it to work on CentOS. This is what I want to achieve, and as I understand it, TigerVNC should be able to handle it:

  • Offer VNC service to several users
  • The user should be asked for username and password
  • It must work with systemd

I have been through more helpful web-pages than I care to list, but the latest, slightly successful one was TigerVNC (on Arch Linux), the section Running Xvnc with XDMCP for on demand sessions.

The system is simple: Ubuntu 20.04 with the default desktop, which seems to be GNOME based - not what I would have chosen, but then this isn't for my use. /var/log/syslog lists a large number of outputs from when I try to connect, but I think the following contains the relevant error:

...
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.Wacom.desktop[555768]: Unable to init server: Could not connect: Connection refused
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.Wacom.desktop[555768]: Cannot open display:
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.Keyboard.desktop[555770]: Unable to init server: Could not connect: Connection refused
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.Keyboard.desktop[555770]: Cannot open display:
Jul 22 14:22:34 megatron gnome-session[555468]: gnome-session-binary[555468]: WARNING: App 'org.gnome.SettingsDaemon.Wacom.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-session-binary[555468]: WARNING: App 'org.gnome.SettingsDaemon.Wacom.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-session-binary[555468]: WARNING: App 'org.gnome.SettingsDaemon.Keyboard.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-session[555468]: gnome-session-binary[555468]: WARNING: App 'org.gnome.SettingsDaemon.Keyboard.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-session-binary[555468]: WARNING: App 'org.gnome.Shell.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-session[555468]: gnome-session-binary[555468]: WARNING: App 'org.gnome.Shell.desktop' exited with code 1
Jul 22 14:22:34 megatron gnome-shell[555777]: Failed to create backend: Unable to open display '127.0.0.1:1'
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.MediaKeys.desktop[555774]: Unable to init server: Could not connect: Connection refused
Jul 22 14:22:34 megatron org.gnome.SettingsDaemon.MediaKeys.desktop[555774]: Cannot open display:
...

On the client side (OSX) I just see a dialog telling me it can't connect. How do I get past this?

Dave M
  • 4,514
  • 22
  • 31
  • 30
j4nd3r53n
  • 226
  • 3
  • 14

1 Answers1

0

Well, my answer is a little late, but I hope it will be helpful nevertheless. I had the same problem with Ubuntu 22.04 and I lost two days for finding a solution.

Try this:

  1. Install TigerVNC, i.e. tigervnc-standalone-server on the server.

  2. Follow the guide for setting up the server, e.g.
    https://docs.01.org/clearlinux/latest/guides/network/vnc.html
    See "Method 3: Multi-user logins with authentication through GDM"
    Short details:
    a) Create a systemd socket file /etc/systemd/system/xvnc.socket with the following content:

     [Unit]
     Description=XVNC Server on port 5900
    
     [Socket]
     ListenStream=5900
     Accept=yes
    
     [Install]
     WantedBy=sockets.target
    

    b) Create a systemd service file /etc/systemd/system/xvnc@.service with the following content:

     [Unit]
     Description=Daemon for each XVNC connection
    
     [Service]
     ExecStart=-/usr/bin/Xvnc -inetd -query localhost -geometry 1920x1200 -once -SecurityTypes=None
     User=nobody
     StandardInput=socket
    

    c) In file /etc/gdm3/custom.conf set:

     [xdmcp]
     Enable=true
     Port=177
    

    d) Start the VNC socket script and set it to start automatically on boot.

    sudo systemctl daemon-reload
    sudo systemctl enable xvnc.socket
    sudo systemctl start xvnc.socket
    

    e) Check. If you do

    systemctl | grep vnc
    

    you should see at least:

    xvnc.socket               loaded active listening XVNC Server on port 5900
    
  3. In the file /etc/gdm3/custom.conf uncomment the line:

    WaylandEnable=false
    

    It solves the problem with black screen right after connection.

  4. Edit:
    In the file /etc/gdm3/custom.conf in section [xdmcp] add:

    DisplaysPerHost=5
    

    Where 5 is example of your max. number of allowed VNC connections.

    It solves the problem "read (104: Connection reset by peer)" for more connections.

  5. In the file /etc/tigervnc/vncserver-config-defaults find parameter $session and set:

    $session = ubuntu
    

    (for the possible session values look at folder /usr/share/xsessions, use names without .desktop suffix)

    It solves the problem with black screen after login screen.

  6. Try to connect from client to <server-ip>:5900.

Alexej S.
  • 1
  • 2