Tuesday, June 25, 2013

Installing VNC SERVER

1. Installing the required packages

The server package is called 'vnc-server'. Run the command: rpm -q vnc-server

The result will be either package vnc-server is not installed or something like vnc-server-4.0-11.el4.

If the server is not installed, install it with the command: yum install vnc-server

The client program is 'vnc'. You can use the command: yum install vnc to install the client if: rpm -q vnc shows that it is not already installed.

Make sure to install a window manager in order to get a full-featured GUI desktop. You can use the command yum groupinstall "GNOME Desktop Environment" to install the Gnome Desktop and requirements, for example. Other popular desktop environments are "KDE" and "XFCE-4.4". XFCE is more light-weight than Gnome or KDE and available from the "extras" repository.

If you are a minimalist, or simply testing, however, it is sufficient to have yum install a simple XTERM client: yum install xterm

If you are running CentOS 6, the command is yum groupinstall Desktop

If you are running CentOS 5, yum groupinstall "GNOME Desktop Environment" may complain about a missing libgaim.so.0. This is a known bug. Please see CentOS-5 FAQ for details.

If you are running CentOS 6, the server is: tigervnc-server not: vnc-server

2. Configuring un-encrypted VNC

We will be setting up VNC for 3 users. These will be 'larry', 'moe', and 'curly'

You will perform the following steps to configure your VNC server:

Create the VNC users accounts.
Edit the server configuration.
Set your users' VNC passwords.
Confirm that the vncserver will start and stop cleanly.
Create and customize xstartup scripts.
Amend the iptables.
Start the VNC service.
Test each VNC user.
Additional optional enhancements
2.1. Create the VNC user accounts
As root:
$ su -
# useradd larry
# useradd moe
# useradd curly
# passwd larry
# passwd moe
# passwd curly
2.2. Edit the server configuration
Edit /etc/sysconfig/vncservers, and add the following to the end of the file.
VNCSERVERS="1:larry 2:moe 3:curly"
VNCSERVERARGS[1]="-geometry 640x480"
VNCSERVERARGS[2]="-geometry 640x480"
VNCSERVERARGS[3]="-geometry 800x600"
Larry will have a 640 by 480 screen, as will Moe. Curly will have an 800 by 600 screen.

Note: This step is NOT out of sequence, but is placed here so that the next following step will fall adjacent to the step in which failure to perform it, will permit immediate fault diagnosis.

2.3. Set your users' VNC passwords
Switch user into the account for each user, and as noted below, run: vncpasswd This will create the ~/.vnc directory for that userid:
[~]# su - larry
[~]$ vncpasswd
[~]$ cd .vnc
[.vnc]$ ls
[.vnc]$ exit
2.4. Confirm that the vncserver will start and stop cleanly
We will create the xstartup scripts by starting and stopping the vncserver as root. We also enable the vncserver service to be automatically started.

# /sbin/service vncserver start
# /sbin/service vncserver stop
# /sbin/chkconfig vncserver on...


2.8.1. Testing with a java enabled browser

Let us assume that mymachine has an IP address of The URL to connect to each of the users will be:
Larry is
Moe is
Curly is
Connect to A java applet window will pop-up showing a connection to your machine at port 1. Click the [ok] button. Enter larry's VNC password, and a 640x480 window should open using the default window manager selected for larry . The above ports 5801, 5802 and 5803 must be open in the firewall {iptables) for the source IP addresses or subnets of a given client.

2.8.2. Testing with a vnc client
For Larry: vncviewer
For Moe: vncviewer
For Curly: vncviewer
To test larry using vncviewer, vncviewer An authentication box will pop up, and you may enter Larry's VNC password. Once authenticated, a 640x480 window should open using Larry's default window manager. The vncviewer client will connect to port 590X where X is an offset of 1,2,3 for Larry, Moe, and Curly respectively, so these ports must be open in the firewall for the IP addresses or subnets of the clients.

If your local account userid is not, say, larry, you may 'switch user' for purposes of vncviewer thus:

export USER=larry ; vncviewer


No comments:

Post a Comment