VNC Server Install

Jun 14, 24

This week’s project has been getting a VNC server running on my file server, something I’ve never done before because I have administered the server using SSH, but it was one of those things that was stuck in my craw because I’d never gotten one going before. In this case, the problem that prevented it from working turned out to be the password file, which the Arch Linux wiki says to set to 600, so then I figured I needed to use root to change it, so

sudo vncpasswd

And then when I issued the command from a remote user:

vncviewer 192.168.1.145

I got prompted for the vnc password and then the lxde login screen appeared.

login

Here’s the problem. That’s what just fixed it and got it running, but I’ve been working on this every day this week in increments, so now I have to retrace my steps a little. I’m trying to keep a better log of my fixes because this ends up being a good resource.

First of all, I mostly used the how-to TigerVNC on Arch Linux. The Arch Linux documentation is almost always the best thing going. In addition to the password fix, I followed the instructions and added a user to the file in /etc/tigervnc/vncserver.users as specified in the file itself. I just used my user account.

Next, I created the file /home/jason/.vnc/config and inserted the following:

session=lxde
geometry=1920x1080
localhost
alwaysshared

Next, I created the file /etc/X11/xorg.conf.d/10-vnc.conf and inserted the following:

Section "Module"
Load "vnc"
EndSection

Section "Screen"
Identifier "Screen0"
Option "UserPasswdVerifier" "VncAuth"
Option "PasswordFile" "/root/.vnc/passwd"
EndSection

I’m just copying and pasting right off the Arch wiki here. I’m pretty sure at this point I created the systemd service and enabled that. To do that, create the file /etc/systemd/system/x0vncserver.service, then add:

[Unit]
Description=Remote desktop service (VNC) for :0 display
Requires=display-manager.service
After=network-online.target
After=display-manager.service

[Service]
Type=simple
Environment=HOME=/root
Environment=XAUTHORITY=/var/run/lxdm/root/:0
ExecStart=x0vncserver -display :0 -rfbauth ~/.vnc/passwd
Restart=on-failure
RestartSec=500ms

[Install]
WantedBy=multi-user.target

Here, I changed the display manager location to lxdm because I’m using lxde. I’m thinking you’d want that to be tailored to your specific configuration.

That’s it, I think. Once the service is enabled and running:

sudo systemctl enable x0vncserver
sudo systemctl status x0vncserver

If it is up and running, try to log in from a remote host.