I have set up TigerVNC on a headless Ubuntu 22.04 server in the cloud, so headless.
Launching
vncserver
as my sudo user works fine and I can connect via an SSH tunnel (although I cannot launch browsers, which is a different issue).
These are the contents of my xstartup file:
#!/bin/sh
test x"$SHELL" = x"" && SHELL=/bin/bash
test x"$1" = x"" && set -- default
vncconfig -iconic &
"$SHELL" -l << EOF
export XDG_SESSION_TYPE=x11
export GNOME_SHELL_SESSION_MODE=ubuntu
dbus-launch --exit-with-session gnome-session --session=ubuntu
EOF
vncserver -kill $DISPLAY
This is the content of /etc/systemd/system/vncserver@.service:
[Unit]
Description=Start TigerVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=user
#Group=user
#WorkingDirectory=/home/user
PAMName=login
PIDFile=/home/user/.vnc/%H:%i.pid
ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -fg -depth 24 -geometry 1920x1080 -localhost :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
When applying sudo service vncserver@1 start
or sudo systemctl start vncserver@1
Syslog records the following:
Oct 16 12:03:25 server systemd[1]: Starting Start TigerVNC server at startup...
Oct 16 12:03:25 server systemd[1]: Started Session 25 of User user.
Oct 16 12:03:25 server vncserver[3049]: vncserver: Option 2>&1: Unrecognized!
Oct 16 12:03:25 server vncserver[3049]: For further help, consult the vncserver(1) and Xtigervnc(1) manual pages.
Oct 16 12:03:25 server systemd[1]: vncserver@1.service: Control process exited, code=exited, status=1/FAILURE
Oct 16 12:03:25 server systemd[1]: vncserver@1.service: Failed with result 'exit-code'.
Oct 16 12:03:25 server systemd[1]: Failed to start Start TigerVNC server at startup.
Oct 16 12:03:25 server systemd[1]: session-25.scope: Deactivated successfully.
I suspect there has been a change in the way recent versions of the software work, but I would appreciate some insight on the matter.