All HowTo's Cyber-Security Linux Redhat, Fedora and CentOS Linux

Install and configure VNC Server for Redhat/CentOS

This article explains how to install and configure VNC Server for Redhat or CentOS. This is the preferred graphical way to remotely manage a Redhat system. Our objective in this tutorial is to allow two users to log in via VNC; the “root” user and the “agix” user. Both will use passwords independent of their shell password.

Find the packages to install:

yum list *vnc*

Amongst other packages, you will see “tigervnc-server”. Install it like this:

yum install tigervnc-server

The above will install the package. Now we need to configure it. Edit the file “/etc/sysconfig/vncserver”. Add the following to the bottom to allow both the “root” user and the “agix” user to use VNC. We’ll run VNC on ports “5900” and “5901”:

VNCSERVERS="0:root,1:agix"
VNCSERVERARGS[0]="-geometry 800x600 -rfbport 5900"
VNCSERVERARGS[1]="-geometry 800x600 -rfbport 5901"

In the above you can see that the “root” user will access VNC on this server on TCP port “5900”. The “agix” user will use tcp port “5901”.

Next we need to make sure it starts on boot.

chkconfig vncserver on

Now we need to create VNC passwords for each user. Each user should run the following command when logged into the shell (perhaps via SSH) as themselves:

vncpasswd

The above creates the file “~/.vnc/passwd”.

Finally we need to permit it through the firewall. Allow TCP ports “5900” and :5901″ in iptables “/etc/sysconfig/iptables”:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT

Start and restart services:

service iptables restart
service vncserver start

At this point you should be done.