Adding VNC Server to Red Hat Enterprise Linux 6.3

Time Required: 10 minutes

Class Materials:

  • Red Hat Enterprise Linux 6.3 64-bit install media

The following steps show how to install a VNC server on Red Hat Enterprise Linux 6.3.

VNC provides a remote desktop solution, allowing users to connect to the Linux system remotely and being able to use the native Linux desktop.

In many Linux distributions, a VNC server is installed by default, but with Red Hat Enterprise Linux 6.x the package must be manually added.

Note: Although the test system for this blog was a RHEL 6.3 system, these steps should work with any RHEL 6.0 or CentOS 6.0 and above Linux system.

First, locate and mount your RHEL 6.3 install media.

[root@localhost ~]# cd "/media/RHEL_6.3 x86_64 Disc 1/Packages"
[root@localhost Packages]# pwd
/media/RHEL_6.3 x86_64 Disc 1/Packages

 
Next load the RPMs to support the VNC server with the following command:

rpm -ivh xorg-x11-fonts-misc-7.2-9.1.el6.noarch.rpm \
tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm

 
My RHEL 6.3 system was originally installed by the VMware Workstation 8.0 Easy Installer, so the only supporting package I need to install the TigerVNC server is xorg-x11-fonts-misc-7.2-9.1.el6.noarch.rpm.

If you did a manual install you might find you need additional packages.

[root@localhost Packages]# rpm -ivh xorg-x11-fonts-misc-7.2-9.1.el6.noarch.rpm \
> tigervnc-server-1.0.90-0.17.20110314svn4359.el6.x86_64.rpm
warning: xorg-x11-fonts-misc-7.2-9.1.el6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:xorg-x11-fonts-misc    ########################################### [ 50%]
   2:tigervnc-server        ########################################### [100%]

 
Before we can start our VNC server, we need to edit the configuration file. The file is located in /etc/sysconfig/vncservers.

In my example I am going to add remote desktop capabilities to my Oracle user id. I am going to set this up with a remote desktop size of 800×600.

To achieve this I am going to add the following:

VNCSERVERS="1:oracle"
VNCSERVERARGS[1]="-geometry 800x600"

 
The first line adds a new VNC listener for the oracle user on port 5901. The second line sets the resolution to 800×600.

You can add additional users to your configuration file. If we wanted to add the user gruffdba to the configuration, it would look like this:

VNCSERVERS="1:oracle 2:gruffdba"
VNCSERVERARGS[1]="-geometry 800x600"
VNCSERVERARGS[2]="-geometry 800x600"

 

Next, we need to set a remote password for users. To do this, log in as the users you added to the VNC server configuration file and use the vncpasswd program to set the password.

[root@localhost Packages]# su - oracle
[oracle@localhost ~]$ vncpasswd
Password:
Verify:
[oracle@localhost ~]$

 

Now let’s set the VNC service to auto-start on boot, and actually start the service.

[root@localhost ~]# chkconfig vncserver on
[root@localhost ~]# service vncserver start
Starting VNC server: 1:oracle 
New 'localhost.localdomain:1 (oracle)' desktop is localhost.localdomain:1

Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/localhost.localdomain:1.log

[  OK  ]

 
Okay, we have an operational VNC server, and you can now connect to your Linux server remotely with a VNC Viewer.

If you completely disabled your firewall, you should now be good to go. If however you cannot connect, it might be that you have a firewall blocking you.

We need to allow connections on port 5901 through the Linux firewall. If you added two users to your VNC server configuration file you will need to open up port 5902 as well. Each additional user added gets the next port number, but in my example I only added one.

The command to add the port to the allow-list is as follows:

iptables -I INPUT -m state --state NEW -p tcp --destination-port 5901 -j ACCEPT

 
If you are having problems, try this and then see if you can connect. You will need to be root to execute the command.

The firewall exception we just added does NOT persist through reboots. In order to make the change permanent, use the following:

[root@localhost ~]# /sbin/service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]

 
You can check what firewall rules you have as follows:

[root@localhost ~]# iptables-save
# Generated by iptables-save v1.4.7 on Tue Mar 26 17:51:12 2013
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [4:608]
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5901 -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1158 -j ACCEPT 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 
-A INPUT -j REJECT --reject-with icmp-host-prohibited 
-A FORWARD -j REJECT --reject-with icmp-host-prohibited 
COMMIT
# Completed on Tue Mar 26 17:51:12 2013

 
Now let’s try connecting to our Linux desktop from my Windows laptop using VNC Viewer. Enter the password you set earlier and you should see your Linux desktop:

Advertisements

8 thoughts on “Adding VNC Server to Red Hat Enterprise Linux 6.3

    • Paul,

      I get the same error only if I try to use a non-existant port, such as :3, which isn’t defined on my test system.

      Which address are you pointing your VNC Viewer at?

      Gruff.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s