Sunday 6 December 2020

Installing TightVNC server in RHEL 7

 Installing TightVNC server for root user and enabling same, every step is performed as root only.


Install VNC with the following command

yum install tigervnc-server

Set password for VNC (no need to enable viewing only) with the following command

vncpasswd

Copy VNC service configuration file to systemd with the following command

cp /lib/systemd/system/vncserver@.service  /etc/systemd/system/vncserver@:1.service

Edit VNC service configuration file with following command

vi /etc/systemd/system/vncserver@\:1.service

Add the following lines after Type=simple. and hashout earlier similar lines present there.

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"

PIDFile=/home/root/.vnc/%H%i.pid

ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

Save file.

Reload systemd enter following commands one by one. (if you are getting any issues in the second command mostly you did a mistake in config file.)

systemctl daemon-reload

systemctl start vncserver@:1

systemctl status vncserver@:1

systemctl enable vncserver@:1

Add exception in firewall with following commands (if any) for allowing VNC.

firewall-cmd --add-port=5901/tcp

firewall-cmd --add-port=5901/tcp --permanent