VNC (Virtual Network Computing) Server allows the remote Desktop sharing using remote VNC clients like VNC viewer. In CentOS 7 & RHEL 7 package named “tigervnc-server” needs to be installed in order to setup the VNC server.
In this article we will go through the installation and configuration of VNC Server on CentOS 7 / RHEL 7.
Step:1 Make Sure the Desktop Packages are installed
In order to setup VNC server first we make sure that Desktop is installed ,in My case i am using Gnome Desktop. If Gnome Desktop is not installed on your Linux machine then use the below command to install.
[root@linuxtechi ~]# yum groupinstall "GNOME Desktop"
Step:2 Install Tigervnc and other dependency Package.
[root@linuxtechi ~]# yum install tigervnc-server xorg-x11-fonts-Type1
Step:3 Setup VNC Server Configuration File.
Copy the VNC config file “/lib/systemd/system/[email protected]” to the “/etc/systemd/system/vncserver@:<Port_Number>.service”.
While Copying the VNC config file we can mention the port number on which we want VNC service to be listen. In my case i am using port 3 , it means VNC will listen on “5903”. So while Connecting to the VNC server We can specify port number as <IP_Address_VNC_Server:3> or <IP_Address_VNC_Server:5903>
[root@linuxtechi ~]# cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:3.service
Step:4 Update the User’s Information in the Config File
[root@linuxtechi ~]# vi /etc/systemd/system/vncserver@:3.service
Replace the “linuxtechi” user as per your requirement. In my case linuxtechi user will able to control and manage its desktop session using remote VNC clients.
Set the Firewall Rule if firewall is enabled on your linux box.
[root@linuxtechi ~]# firewall-cmd --permanent --zone=public --add-port=5903/tcp success [root@linuxtechi ~]# firewall-cmd --reload success [root@linuxtechi ~]#
Step:5 Set the VNC password for the User.
Switch to the user (linuxtechi) and run vncserver command to set the password as shown below :
Start and Enable the VNC Service at boot.
Execute below commands as root only.
[root@linuxtechi ~]# systemctl daemon-reload [root@linuxtechi ~]# systemctl start vncserver@:3.service [root@linuxtechi ~]# systemctl enable vncserver@:3.service ln -s '/etc/systemd/system/vncserver@:3.service' '/etc/systemd/system/multi-user.target.wants/vncserver@:3.service' [root@linuxtechi ~]#
Step:6 Access Remote Desktop Session.
From Ubuntu Machine :
ubuntu@localhost:~$ vncviewer 192.168.1.15:3
Enter the VNC password that we have set in above step, after validating the authentication Remote Desktop session will start.
From Windows Machine Using VNC Viewer
Enter the VNC Server IP Address and Port Number and then Click on OK
Enter the VNC Password & then click on OK.
Desktop Session Will start after authentication.
systemctl start vncserver@:1.service
Job for vncserver@:1.service failed because a configured resource limit was exceeded. See “systemctl status vncserver@:1.service” and “journalctl -xe” for details.
run below command to resolve this issue
rm -f /tmp/.X11-unix/X1
systemctl start vncserver@:1.service
Works for root user but unable to duplicate the process for any other user on the system.
vncserver@:2.service – Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)
Active: failed (Result: protocol) since Fri 2020-07-31 14:38:01 EDT; 3min 1s ago
Process: 5814 ExecStart=/sbin/runuser -l copuser -c /usr/bin/vncserver :2 -geometry 1280×1024 (code=exited, status=0/SUCCESS)
Process: 5810 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :2 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Jul 31 14:37:58 dev-rhel8-tew.gccsj.nn.c2fse.northgrum.com systemd[1]: Starting Remote desktop service (VNC)…
Jul 31 14:38:01 dev-rhel8-tew.gccsj.nn.c2fse.northgrum.com systemd[1]: vncserver@:2.service: Can’t open PID file /home/copuser/.vnc/dev-rhel8-tew.gccsj.nn.c2fse.northgrum.com:2.pid (yet?) after start: No such file or directory
Jul 31 14:38:01 dev-rhel8-tew.gccsj.nn.c2fse.northgrum.com systemd[1]: vncserver@:2.service: Failed with result ‘protocol’.
Jul 31 14:38:01 dev-rhel8-tew.gccsj.nn.c2fse.northgrum.com systemd[1]: Failed to start Remote desktop service (VNC).
Thanks for the post. I was struggling as in other links where it was mention,
$ su –
$ vncpasswd
but as in your post step-5,
#su –
#vncserver
It works for me. i.e. “vncserver” command.
my vncserver service unit file is
[vncu1@vnc-test ~]$sudo cat /etc/systemd/system/vncserver@:6.service
#####################################################
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/usr/bin/vncserver_wrapper %i
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
[Install]
WantedBy=multi-user.target
#####################################################
here Type=simple