How to setup TigerVNC on CentOS 6


While alternatives are available, the simplest way to configure remote access to CentOS Linux is via VNC. In our example we will use TigervVnc. TigerVNC is feature rich and has built-in encryption support. Alternatively you could use TurboVNC , TightVNC and so on.

Server Configuration

We will start with server configuration or the system to which you want to get remote access system A in our case. As always, the simplest method to install these packages is with the yum package manager.

#yum install tigervnc-server

Once they are installed, you can start the configuration process in the /etc/sysconfig/vncservers file. The last two lines in the default version of the file is where most configuration changes will take please: In the example below user john will be allowed to stat vnc on port 5902.

vi /etc/sysconfig/vncservers
#VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

The first directive would work for a single username; for example, the following line would work for two usernames. The username associated with the number does not matter; however, the numbers should be consecutive. In addition, the numbers shown here correspond to VNC port numbers. For example, the line shown here matches user michael and elizabeth to port numbers 5901 and 5902, respectively.

VNCSERVER=”1:john 2:peter”

Now save the changes and get the VNC service going. The following sequence of actions will seem counterintuitive. To start the VNC service, you first have to make sure it’s stopped, with the following command:

#/etc/init.d/vncserver stop

Now set up one of the users associated with the VNCSERVER directive just configured. You’ll have to do so from that user’s account with the vncserver command. The first available port is assumed, unless one is specified. The following command specifies a connection through port 5902 (not 2):

# su john
$ vncserver :2

Now check the result with the following command. It should confirm that VNC servers are actually running.

# /etc/init.d/vncserver status

More detailed configuration is possible. The following command adds more information, which in this case overrides the GUI window dimensions set in the

/etc/sysconfig/vncservers configuration file:

$vncserver :2 -geometry 640x400

Client Configuration

You should be able to connect to from remote system (B in our case ) to vncserver with vncviewer command. Run the following command on remote clinet with x.x.x.x being ip address of vnc servers , you could use hostname if name resolution is in place.

# vncviewer x.x.x.x:2


Firewall Ports

he ports to be open in a firewall depend on the number of connections that may be made to the local VNC server. At minimum, you’ll need to open ports 5900 and 5901. The additional ports that you open depend on the number of connections needed from remote systems