I am trying to configure TigerVNC Server to run on Ubuntu GNOME 16.04.3. I installed the latest version (1.8) of TigerVNC using this post. If I start a server using:
vncserver :4 -geometry 1920x1080 -depth 24 -nolisten tcp -localhost
it works perfectly. I can connect to display 4 over SSH, and have full access to my computer, without unlocking the real (physical) displays in my lab. Also, I can tune the geometry to match my laptop's display, so everything is perfect.
Then I tried to get the server to start at startup, using systemd
, and I found this post to help me. However, I am running the GNOME desktop, and the settings from the blog are for Unity. I do not have Unity installed on my machine, and I would prefer to avoid it.
How do I modify steps 7 and 8 in that post to use GNOME desktop instead of Unity? I know that it does not work if they are skipped, as I just get a black screen when I connect remotely.
In fact, if there is another way to ensure vncserver
is started at startup, that will be accepted as answer as well. TigerVNC does install a script called vncserver
in /etc/init.d/
, but I am not able to launch it using update-rc.d
Best Answer
This
systemd
Unit file worked for me:Be sure to replace
user
with your actual username on lines corresponding toUser
andPIDFile
under[Service]
.vncserver@.service
in/etc/systemd/system/
systemctl enable vncserver@4.service
which creates a symlink filevncserver@4.service
in/etc/systemd/system/multi-user.target.wants/
pointing tovncserver@.service
in/etc/systemd/system/
systemctl start vncserver@4
To adapt it to your needs, please use your preferred display number instead of 4 (as I did) when enabling. Also, ensure that you have initialized the vncserver outside of this service Unit file before starting the service. This would ensure the password, and the necessary files (
xstartup
, etc.) are created. The easiest way to do that would be to run the command againstExecStart
under[Service]
in the Unit file. For my case, that translates to:Source: I adapted the Unit file from this guide.