CentOS 7: How to Install and Configure VNC server?


I. Install xfce Desktop:

Step 1:
CentOS 7: how to install xfce Desktop

II. Install VNC Server

Step 2:

yum install tigervnc-server

Result:

[tutorialspots@tutorialspots ~]# yum install tigervnc-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos-tx.psychz.net
 * epel: kdeforge2.unl.edu
 * extras: repo.miserver.it.umich.edu
 * ius: muug.ca
 * nux-dextop: mirror.li.nux.ro
 * remi-safe: mirror.bebout.net
 * updates: mirror.compevo.com
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.8.0-13.el7 will be installed
--> Processing Dependency: xorg-x11-xinit for package: tigervnc-server-1.8.0-13.el7.x86_64
--> Processing Dependency: xorg-x11-xauth for package: tigervnc-server-1.8.0-13.el7.x86_64
--> Processing Dependency: tigervnc-server-minimal for package: tigervnc-server-1.8.0-13.el7.x86_64
--> Running transaction check
---> Package tigervnc-server-minimal.x86_64 0:1.8.0-13.el7 will be installed
--> Processing Dependency: xorg-x11-xkb-utils for package: tigervnc-server-minimal-1.8.0-13.el7.x86_64
--> Processing Dependency: tigervnc-license for package: tigervnc-server-minimal-1.8.0-13.el7.x86_64
--> Processing Dependency: libXfont2.so.2()(64bit) for package: tigervnc-server-minimal-1.8.0-13.el7.x86_64
--> Processing Dependency: libXdmcp.so.6()(64bit) for package: tigervnc-server-minimal-1.8.0-13.el7.x86_64
---> Package xorg-x11-xauth.x86_64 1:1.0.9-1.el7 will be installed
---> Package xorg-x11-xinit.x86_64 0:1.3.4-2.el7 will be installed
--> Processing Dependency: xorg-x11-server-utils for package: xorg-x11-xinit-1.3.4-2.el7.x86_64
--> Running transaction check
---> Package libXdmcp.x86_64 0:1.1.2-6.el7 will be installed
---> Package libXfont2.x86_64 0:2.0.3-1.el7 will be installed
---> Package tigervnc-license.noarch 0:1.8.0-13.el7 will be installed
---> Package xorg-x11-server-utils.x86_64 0:7.7-20.el7 will be installed
--> Processing Dependency: libXxf86misc.so.1()(64bit) for package: xorg-x11-server-utils-7.7-20.el7.x86_64
---> Package xorg-x11-xkb-utils.x86_64 0:7.7-14.el7 will be installed
--> Processing Dependency: libxkbfile.so.1()(64bit) for package: xorg-x11-xkb-utils-7.7-14.el7.x86_64
--> Running transaction check
---> Package libXxf86misc.x86_64 0:1.0.3-7.1.el7 will be installed
---> Package libxkbfile.x86_64 0:1.0.9-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                      Arch        Version               Repository
                                                                           Size
================================================================================
Installing:
 tigervnc-server              x86_64      1.8.0-13.el7          base      215 k
Installing for dependencies:
 libXdmcp                     x86_64      1.1.2-6.el7           base       34 k
 libXfont2                    x86_64      2.0.3-1.el7           base      143 k
 libXxf86misc                 x86_64      1.0.3-7.1.el7         base       19 k
 libxkbfile                   x86_64      1.0.9-3.el7           base       83 k
 tigervnc-license             noarch      1.8.0-13.el7          base       29 k
 tigervnc-server-minimal      x86_64      1.8.0-13.el7          base      1.0 M
 xorg-x11-server-utils        x86_64      7.7-20.el7            base      178 k
 xorg-x11-xauth               x86_64      1:1.0.9-1.el7         base       30 k
 xorg-x11-xinit               x86_64      1.3.4-2.el7           base       58 k
 xorg-x11-xkb-utils           x86_64      7.7-14.el7            base      103 k

Transaction Summary
================================================================================
Install  1 Package (+10 Dependent packages)

Total download size: 1.9 M
Installed size: 4.4 M
Is this ok [y/d/N]: y
Downloading packages:
(1/11): libXdmcp-1.1.2-6.el7.x86_64.rpm                    |  34 kB   00:00
(2/11): libXxf86misc-1.0.3-7.1.el7.x86_64.rpm              |  19 kB   00:00
(3/11): libXfont2-2.0.3-1.el7.x86_64.rpm                   | 143 kB   00:00
(4/11): tigervnc-license-1.8.0-13.el7.noarch.rpm           |  29 kB   00:00
(5/11): libxkbfile-1.0.9-3.el7.x86_64.rpm                  |  83 kB   00:00
(6/11): tigervnc-server-1.8.0-13.el7.x86_64.rpm            | 215 kB   00:00
(7/11): xorg-x11-server-utils-7.7-20.el7.x86_64.rpm        | 178 kB   00:00
(8/11): tigervnc-server-minimal-1.8.0-13.el7.x86_64.rpm    | 1.0 MB   00:00
(9/11): xorg-x11-xauth-1.0.9-1.el7.x86_64.rpm              |  30 kB   00:00
(10/11): xorg-x11-xinit-1.3.4-2.el7.x86_64.rpm             |  58 kB   00:00
(11/11): xorg-x11-xkb-utils-7.7-14.el7.x86_64.rpm          | 103 kB   00:00
--------------------------------------------------------------------------------
Total                                              3.7 MB/s | 1.9 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : 1:xorg-x11-xauth-1.0.9-1.el7.x86_64                         1/11
  Installing : tigervnc-license-1.8.0-13.el7.noarch                        2/11
  Installing : libXdmcp-1.1.2-6.el7.x86_64                                 3/11
  Installing : libXfont2-2.0.3-1.el7.x86_64                                4/11
  Installing : libxkbfile-1.0.9-3.el7.x86_64                               5/11
  Installing : xorg-x11-xkb-utils-7.7-14.el7.x86_64                        6/11
  Installing : tigervnc-server-minimal-1.8.0-13.el7.x86_64                 7/11
  Installing : libXxf86misc-1.0.3-7.1.el7.x86_64                           8/11
  Installing : xorg-x11-server-utils-7.7-20.el7.x86_64                     9/11
  Installing : xorg-x11-xinit-1.3.4-2.el7.x86_64                          10/11
  Installing : tigervnc-server-1.8.0-13.el7.x86_64                        11/11
  Verifying  : xorg-x11-xinit-1.3.4-2.el7.x86_64                           1/11
  Verifying  : libXxf86misc-1.0.3-7.1.el7.x86_64                           2/11
  Verifying  : libxkbfile-1.0.9-3.el7.x86_64                               3/11
  Verifying  : tigervnc-server-minimal-1.8.0-13.el7.x86_64                 4/11
  Verifying  : libXfont2-2.0.3-1.el7.x86_64                                5/11
  Verifying  : xorg-x11-server-utils-7.7-20.el7.x86_64                     6/11
  Verifying  : libXdmcp-1.1.2-6.el7.x86_64                                 7/11
  Verifying  : xorg-x11-xkb-utils-7.7-14.el7.x86_64                        8/11
  Verifying  : tigervnc-license-1.8.0-13.el7.noarch                        9/11
  Verifying  : tigervnc-server-1.8.0-13.el7.x86_64                        10/11
  Verifying  : 1:xorg-x11-xauth-1.0.9-1.el7.x86_64                        11/11

Installed:
  tigervnc-server.x86_64 0:1.8.0-13.el7

Dependency Installed:
  libXdmcp.x86_64 0:1.1.2-6.el7
  libXfont2.x86_64 0:2.0.3-1.el7
  libXxf86misc.x86_64 0:1.0.3-7.1.el7
  libxkbfile.x86_64 0:1.0.9-3.el7
  tigervnc-license.noarch 0:1.8.0-13.el7
  tigervnc-server-minimal.x86_64 0:1.8.0-13.el7
  xorg-x11-server-utils.x86_64 0:7.7-20.el7
  xorg-x11-xauth.x86_64 1:1.0.9-1.el7
  xorg-x11-xinit.x86_64 0:1.3.4-2.el7
  xorg-x11-xkb-utils.x86_64 0:7.7-14.el7

Complete!

Step 3: Start vncserver : vncserver

[tutorialspots@tutorialspots ~]$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used

New 'tutorialspots.net:1 (tutorialspots)' desktop is tutorialspots.net:1

Creating default startup script /home/tutorialspots/.vnc/xstartup
Creating default config /home/tutorialspots/.vnc/config
Starting applications specified in /home/tutorialspots/.vnc/xstartup
Log file is /home/tutorialspots/.vnc/tutorialspots.net:1.log

III. Configuring VNC Server

Step 4. Edit file ~/.vnc/xstartup

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 

Step 5: Edit file ~/.vnc/config

# securitytypes=vncauth,tlsvnc
# desktop=sandbox
geometry=1920x1080
# localhost
# alwaysshared
dpi=96

Step 6:

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

Content example:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=tutorialspots
Group=tutorialspots

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

[Install]
WantedBy=multi-user.target

Step 11:

su -
systemctl stop vncserver@:1.service
systemctl daemon-reload
systemctl enable vncserver@:1.service
systemctl start vncserver@:1.service

If error you can reboot your server.

Check status:

systemctl status vncserver@:1.service

IV. Connect to VNC server

Step 7(optinal – recommended): Set Up SSH Tunneling for more security

ssh -L 5901:127.0.0.1:5901 -N -f -l tutorialspots ipserver

Example for Windows (Cygwin):

D:\cygwin64\bin>ssh -L 5901:127.0.0.1:5901 -N -f -l tutorialspots 198.204.228.20

tutorialspots@198.204.228.20's password:

Step 8: Connecting using Real Vncviewer

realvncviewer

real vncviewer connect

real vncviewer connect successfully

1 Comment

Leave a Reply