If you already have a VNC Server, then you will know how this works. We’re going to add another user to the VNC. It’s a very similar process to going through the initial installation process.
Go ahead and log in to your system and switch over to root… If you are not already signed in as root.
su -
Next well need to copy/paste a new vnc config file, like before.
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
Since this is a different user, well need to use a different port. indicated by the “@:2”. The new port will be 5902.
Edit the config file.
vi /etc/systemd/system/vncserver@:2.service
[Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' #ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i" #PIDFile=/home/<USER>/.vnc/%H%i.pid ExecStart=/sbin/runuser -l test-c "/usr/bin/vncserver %i" PIDFile=/home/test/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
After you have added the new user, go ahead and move over to the account.
su - test
Start vncserver
vncserver
Once again, it will ask for a password. THis password is for when you are connecting to the server.
Finally, you will need to enter the following commands to enable/start the services.
systemctl daemon-reload
systemctl enable vncserver@:2.service
Restart your system and then log back in when the system is back online.
systemctl start vncserver@:2.service
You can also use this process to add Root to the VNC users.