How to Install and Configure TigerVNC Server on CentOS 7.1 / RHEL 7.1 / Oracle Linux 7

The following article explain how to Install and configure TigerVNC Server on CentOS 7.1 or Red Hat Enterprise Linux (RHEL 7.1) or Oracle Linux 7. TigerVNC (Tiger Virtual Network Computing) is a remote access utility that allows you to control other computers that running graphical desktop sharing in separate sessions in parallel. It is works on the client-server principle: a server shares its output (vncserver) and a client (vncviewer) connects to the server. TigerVNC in RHEL 7 or CentOS 7 or Oracle Linux 7 uses the systemd system management daemon for its configuration. The /etc/sysconfig/vncserver configuration file has been replaced by /etc/systemd/system/vncserver@.service.

Install and Configure TigerVNC Server on Linux

1. Install tigervnc-server

# yum install tigervnc-server -y

2. Copy this file to /etc/systemd/system/vncserver@:.service :

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

3. Edit and vncserver parameters appropriately

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

Replace with actual user hat exist on the linux (e.g ehowstuff)

[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 ehowstuff -c "/usr/bin/vncserver %i"
PIDFile=/home/ehowstuff/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

4. Run `systemctl daemon-reload` to make the changes take effect immediately :

# systemctl daemon-reload

5. Set the password for the user or users defined in the configuration file. Note that you need to switch from root to USER first.

# su - ehowstuff
$ vncpasswd
Password:
Verify:

6. To start the service, specify the display number directly in the command :

# systemctl start vncserver@:1.service

7. Enable the service to start automatically at system start

# systemctl enable vncserver@:1.service

8. Add firewall rules to allow the VNC connection :

# firewall-cmd --permanent --zone=public --add-port 5901/tcp
# systemctl restart firewalld.service

9. Run VNC viewer :
Configure TigerVNC Server

How to Setup VNC Server on CentOS 6.3

VNC-logoVNC is a protocol that is used to display an X windows session running on another computer over the network. VNC server must be install at the target(destination) workstation and source or client will access the target workstatio using VNC client. In this post, it was assumed that the VNC server will be install on CentOS 6.3 and will be access by Win XP client using portable VNC client(VNC viewer). Meaning to say that the desktop on CentOS will be shared with others. If you are running CentOS 5 and below, yum command install will recognize vnc-server. But in CentOS 6, If you are running CentOS 6, the server is: tigervnc-server not: vnc-server will be replace with tigervnc-server not.

1. Install VNC server on CentOS 6.3 using yum command :

[root@CentOS6 ~]# yum install tigervnc-server -y

2. As a root, create the user that will use VNC user accounts :

[root@CentOS6 ~]# useradd ehowstuff
[root@CentOS6 ~]# useradd mhstar
[root@CentOS6 ~]# passwd ehowstuff
[root@CentOS6 ~]# passwd mhstar

3. Edit /etc/sysconfig/vncservers, and add the following :

VNCSERVERS="1:ehowstuff 2:mhstar"
VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[2]="-geometry 640x480"

ehowstuff will have an 800 by 600 screen and mhstar will have a 640×480 screen.

4. Set VNC passwords for each users :

[root@CentOS6 ~]# su - ehowstuff
[ehowstuff@CentOS6 ~]$ vncpasswd
Password:
Verify:
[ehowstuff@CentOS6 ~]$ cd .vnc
[ehowstuff@CentOS6 .vnc]$ ls
passwd
[ehowstuff@CentOS6 .vnc]$ exit
logout
[root@CentOS6 ~]# su - mhstar
[mhstar@CentOS6 ~]$ vncpasswd
Password:
Verify:
[mhstar@CentOS6 ~]$ cd .vnc
[mhstar@CentOS6 .vnc]$ ls
passwd
[mhstar@CentOS6 .vnc]$ exit
logout

Switch user into the account for each user. Run vncpasswd will create the ~/.vnc directory.

5. Start vncserver as a root :

[root@CentOS6 ~]# service vncserver start
Starting VNC server: 1:ehowstuff xauth:  creating new authority file /home/ehowstuff/.Xauthority
xauth: (stdin):1:  bad display name "CentOS6.3:1" in "add" command

New 'CentOS6.3:1 (ehowstuff)' desktop is CentOS6.3:1

Creating default startup script /home/ehowstuff/.vnc/xstartup
Starting applications specified in /home/ehowstuff/.vnc/xstartup
Log file is /home/ehowstuff/.vnc/CentOS6.3:1.log

2:mhstar xauth:  creating new authority file /home/mhstar/.Xauthority
xauth: (stdin):1:  bad display name "CentOS6.3:2" in "add" command

New 'CentOS6.3:2 (mhstar)' desktop is CentOS6.3:2

Creating default startup script /home/mhstar/.vnc/xstartup
Starting applications specified in /home/mhstar/.vnc/xstartup
Log file is /home/mhstar/.vnc/CentOS6.3:2.log

                                                           [  OK  ]

6. Stopping the vncserver as root :

[root@CentOS6 ~]# service vncserver stop
Shutting down VNC server: 1:ehowstuff 2:mhstar             [  OK  ]

7. Set the VNC service to be automatically start at boot :

[root@CentOS6 ~]# chkconfig vncserver on

8. Use VNC viewer to connect VNC server :


Example :