VNC server installation and configuration on CentOS 7/RHEL 7


VNC Server

VNC means Virtual Network Computing. Which is used to control the remote systems by using Remote frame buffer protocol.  It is cross-platform application, available for Linux, windows and Macintosh systems. There are two types of vnc services i.e VNC Server and VNC Client. Multiple clients may connect to a vnc server at the same time. This VNC Service is provided by Tiger VNC package.
In this article, we will learn about the Tiger VNC server installation on centOS7 and how to connect from vnc client(vnc viewer) to vnc server.
Install the tiger vnc server by using following command

[root@localhost ~]# yum -y install tigervnc*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Package tigervnc-license-1.3.1-9.el7.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package tigervnc.x86_64 0:1.3.1-9.el7 will be installed
--> Processing Dependency: for package: tigervnc-1.3.1-9.el7.x86_64
--> Processing Dependency: for package: tigervnc-1.3.1-9.el7.x86_64
---> Package tigervnc-icons.noarch 0:1.3.1-9.el7 will be installed
---> Package tigervnc-server.x86_64 0:1.3.1-9.el7 will be installed
---> Package tigervnc-server-applet.noarch 0:1.3.1-9.el7 will be installed
---> Package tigervnc-server-minimal.x86_64 0:1.3.1-9.el7 will be installed
---> Package tigervnc-server-module.x86_64 0:1.3.1-9.el7 will be installed
--> Running transaction check
---> Package fltk.x86_64 0:1.3.0-13.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                                             Arch                               Version                                  Repository                        Size
 tigervnc                                            x86_64                             1.3.1-9.el7                              base                             211 k
 tigervnc-icons                                      noarch                             1.3.1-9.el7                              base                              36 k
 tigervnc-server                                     x86_64                             1.3.1-9.el7                              base                             203 k
 tigervnc-server-applet                              noarch                             1.3.1-9.el7                              base                             417 k
 tigervnc-server-minimal                             x86_64                             1.3.1-9.el7                              base                             1.0 M
 tigervnc-server-module                              x86_64                             1.3.1-9.el7                              base                             246 k
Installing for dependencies:
 fltk                                                x86_64                             1.3.0-13.el7                             base                             654 k

Transaction Summary
Install  6 Packages (+1 Dependent package)

Total download size: 2.7 M
Installed size: 6.1 M
Downloading packages:
(1/7): tigervnc-server-1.3.1-9.el7.x86_64.rpm                                                                                                    | 203 kB  00:00:01
(2/7): tigervnc-server-applet-1.3.1-9.el7.noarch.rpm                                                                                             | 417 kB  00:00:05
(3/7): tigervnc-server-module-1.3.1-9.el7.x86_64.rpm                                                                                             | 246 kB  00:00:01
(4/7): tigervnc-icons-1.3.1-9.el7.noarch.rpm                                                                                                     |  36 kB  00:00:06
(5/7): tigervnc-1.3.1-9.el7.x86_64.rpm                                                                                                           | 211 kB  00:00:07
(6/7): tigervnc-server-minimal-1.3.1-9.el7.x86_64.rpm                                                                                            | 1.0 MB  00:00:07
(7/7): fltk-1.3.0-13.el7.x86_64.rpm                                                                                                              | 654 kB  00:00:13
Total                                                                                                                                   208 kB/s | 2.7 MB  00:00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tigervnc-server-minimal-1.3.1-9.el7.x86_64                                                                                                           1/7
  Installing : tigervnc-server-1.3.1-9.el7.x86_64                                                                                                                   2/7
  Installing : fltk-1.3.0-13.el7.x86_64                                                                                                                             3/7
  Installing : tigervnc-icons-1.3.1-9.el7.noarch                                                                                                                    4/7
  Installing : tigervnc-1.3.1-9.el7.x86_64                                                                                                                          5/7
  Installing : tigervnc-server-applet-1.3.1-9.el7.noarch                                                                                                            6/7
  Installing : tigervnc-server-module-1.3.1-9.el7.x86_64                                                                                                            7/7
  Verifying  : tigervnc-1.3.1-9.el7.x86_64                                                                                                                          1/7
  Verifying  : tigervnc-server-1.3.1-9.el7.x86_64                                                                                                                   2/7
  Verifying  : tigervnc-server-applet-1.3.1-9.el7.noarch                                                                                                            3/7
  Verifying  : tigervnc-icons-1.3.1-9.el7.noarch                                                                                                                    4/7
  Verifying  : fltk-1.3.0-13.el7.x86_64                                                                                                                             5/7
  Verifying  : tigervnc-server-module-1.3.1-9.el7.x86_64                                                                                                            6/7
  Verifying  : tigervnc-server-minimal-1.3.1-9.el7.x86_64                                                                                                           7/7

  tigervnc.x86_64 0:1.3.1-9.el7                          tigervnc-icons.noarch 0:1.3.1-9.el7                     tigervnc-server.x86_64 0:1.3.1-9.el7
  tigervnc-server-applet.noarch 0:1.3.1-9.el7            tigervnc-server-minimal.x86_64 0:1.3.1-9.el7            tigervnc-server-module.x86_64 0:1.3.1-9.el7

Dependency Installed:
  fltk.x86_64 0:1.3.0-13.el7

[root@localhost ~]#

Now copy the configuration file

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

Now edit the file replace user entries with the username whom we allow to access the server through the vnc viewer. In my case that is nagaramesh

#vi /etc/stems/system/vncserver@:.service

change <USER> to nagaramesh as follows

Now create vnc password it is differ from original login password


Now enable and start vnc service as follows

#systemctl enable vncserver@:1.service
#systemctl start vncserver@:1.service

Now add firewall rules to allow the vnc service

#firewall-cmd --zone=public --permanent --add-service=vncserver
#firewall-cmd reload

Now the server is ready. We can check the status of VNC server as follows

[root@localhost ~]# systemctl status vncserver@:1.service
● vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2017-02-20 10:20:49 IST; 3min 20s ago
  Process: 5729 ExecStart=/usr/sbin/runuser -l nagaramesh -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
  Process: 5727 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 5755 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           ‣ 5755 /usr/bin/Xvnc :1 -desktop localhost.localdomain:1 (nagaramesh) -httpd /usr/share/vnc/classes -auth /home/nagarame...

Feb 20 10:20:46 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
Feb 20 10:20:49 localhost.localdomain systemd[1]: Started Remote desktop service (VNC).

Now access the server through VNC.

Once we click on continue it prompts for vnc password

Input the password and click on Ok to connect to server

Enjoy VNC server, if you want to join this discussion, feel free to leave a comment!