Solved vncserver terminates unless run with sudo

Solved issue

zzzhhh

New Member
Joined
Jan 5, 2024
Messages
6
Reaction score
1
Credits
87
I installed Ubuntu 22.04.3 LTS in WSL2 and tried to connect GNOME desktop using VNC. To that end, I installed ubuntu-gnome-desktop, tigervnc-standalone-server, dbus-x11 packages and ran sudo systemctl set-default multi-user.target command.

In normal Ubuntu, I can run vncserver without sudo and it will prompt me for password, create a passwd file in .vnc directory and exit without any error. But in WSL, I received the following errors:
~$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used

New Xtigervnc server 'DESKTOP-J2VCDBO.:2 (<my user name>)' on port 5902 for display :2.
Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/<my user name>/.vnc/passwd :2 to connect to the VNC server.


=================== tail /home/<my user name>/.vnc/DESKTOP-J2VCDBO.:5902.log ===================
Terminated
X connection to :2 broken (explicit kill or server shutdown).

Thu Jan 4 03:01:44 2024
ComparingUpdateTracker: 0 pixels in / 0 pixels out
ComparingUpdateTracker: (1:-nan ratio)
Killing Xtigervnc process ID 21419... success!
======================================================================================

Session startup via '/etc/X11/Xtigervnc-session' cleanly exited too early (< 3 seconds)!

Maybe try something simple first, e.g.,
tigervncserver -xstartup /usr/bin/xterm
The Xtigervnc server cleanly exited!
The X session cleanly exited!

Below is the whole log file .vnc/DESKTOP-J2VCDBO.\:5902.log:
Xvnc TigerVNC 1.12.0 - built 2022-03-25 17:06
Copyright (C) 1999-2021 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12101003, X.Org


Thu Jan 4 03:31:12 2024
vncext: VNC extension running!
vncext: Listening for VNC connections on local interface(s), port 5902
vncext: created VNC server for screen 0
[mi] mieq: warning: overriding existing handler (nil) with 0x55d124219400 for event 2
[mi] mieq: warning: overriding existing handler (nil) with 0x55d124219400 for event 3
3NI3X0 New Xtigervnc server 'DESKTOP-J2VCDBO.:2 (<my user name>)' on port 5902 for display :2.
3NI3X0 Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/<my user name>/.vnc/passwd :2 to connect to the VNC server.
Terminated

Thu Jan 4 03:31:13 2024
ComparingUpdateTracker: 0 pixels in / 0 pixels out
ComparingUpdateTracker: (1:-nan ratio)
X connection to :2 broken (explicit kill or server shutdown).
Killing Xtigervnc process ID 32892... success!

Below are contents of file .xsession-errors
Xsession: X session started for <my user name> at Fri Jan 5 03:30:26 EST 2024
dbus-update-activation-environment: setting DISPLAY=:1
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
localuser:zhou being added to access control list
dbus-update-activation-environment: setting GTK_MODULES=gail:atk-bridge
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
dbus-update-activation-environment: setting QT_ACCESSIBILITY=1
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
dbus-update-activation-environment: setting VNCDESKTOP=DESKTOP-J2VCDBO.:1 (<my user name>)
dbus-update-activation-environment: setting LESSOPEN=| /usr/bin/lesspipe %s
... ...

If, however, I run vncserver with sudo, it runs as in normal Ubuntu without any errors, and I can proceed to display the GNOME desktop through VNC connection in MobaXterm.

I'm looking to understand why sudo makes the difference and how to run vncserver correctly without sudo. Thanks.
 
Last edited:


I think this problem is solved.

vncserver can be run as normal user when using systemd in WSL. But previously, SSH server did not work with systemd, as another question of mine mentioned, so I didn't use systemd and thus vncserver can't be run as normal user.

But WSL released a new version 2.0.14 this morning, after I submitted this ticket (what a coincidence). In this version of WSL, SSH works with systemd (though systemctl reports the SSH service is inactive (dead)), so I use systemd in WSL and vncserver can be run as normal user now.
 
...as I said with the other Thread if you think it is solved.

Wiz
 


Top