VNC




Installing TigerVNC Server on CentOS 7

VNC-Server Configuration:
The TigerVNC Server package is available in CentOS 7 base repo:
# yum install tigervnc-server

VNC service will run on port 5900 (vncserver@.service).
vncserver@#.service – to setup a second instance of vnc server for a second user, change the # to 1 vncserver@1.service and it will use port 5901. So a third user will be vncserver@2.service and will use port 5902.
Copy the service from /lib/systemd/system/ to /etc/systemd/system/
# cp /lib/systemd/system/vncserver@.service \
# /etc/systemd/system/vncserver@:1.service

Edit vncserver@:1.service
Replace the USER with your your vnc user:
# vim /etc/systemd/system/vncserver@:1.service

# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l  -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.service`
#
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[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
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

Create a VNC Password
su to the vnc user and run vncserver:

$ vncserver

You will require a password to access your desktops.

Password:
Verify:
xauth:  file /home/ferdy/.Xauthority does not exist

New 'myVNCServer:1 (ferdy)' desktop is myVNCServer:1

Creating default startup script /home/ferdy/.vnc/xstartup
Starting applications specified in /home/ferdy/.vnc/xstartup
Log file is /home/ferdy/.vnc/myVNCServer:1.log

Start the VNC Server:
# systemctl daemon-reload
# systemctl restart vncserver@:1.service

Enable it at boot time:
# systemctl enable vncserver@:1.service

Configure Firewall to allow VNC Port 5901:
# firewall-cmd –permanent –zone=public –add-port=5901/tcp
# firewall-cmd –reload

Installing TigerVNC viewer or client on CentOS 7 client:
# yum install tigervnc

The VNC viewer launcher will be located at:
Main Menu -> Internet -> TigerVNC Viewer


Published by

Ferdy Mañago

Portland, Oregon