jump to navigation

How to setup vnc-server on Centos 5.x / Fedora 11 February 2, 2011

Posted by Tournas Dimitrios in Linux.

VNC stands for Virtual Network Computing. It is remote control software which allows you to view and interact with one computer (the “server”) using a simple program (the “viewer”) on another computer anywhere on the Internet. The two computers don’t even have to be the same type, so for example you can use VNC to view an office Linux machine on your Windows PC at home. VNC is freely and publicly available and is in widespread active use by millions throughout industry, academia and privately.
Actually vnc is an alternative to ssh , but without encryption …. So be careful with your sensitive data . Of course it is possible to tunnel vnc through an ssh-tunnel ,but that is a story for another article🙂 .

The process for setting up a vnc client / server model is simple simple , just follow these five steps:

  1. Installing the packages
  2. Configuring the files for the server .
  3. Setting password for the server .
  4. Starting the server .
  5. Connecting from a client (remote host) .

  • Installing the packages : First do an rpm-query to verify that the package is installed
    [root@Oldserver ~]# rpm -qa |grep vnc
    By default the package is not installed by any Linux distro , so do a manual installation . EPEL repository provide us the package ready to download –> yum install  vnc-server . Alternatively go to this website and download the rpm package and make a manual installation with –> rpm -ivh  vnc-4.xxxx.rpm . On my CentOs 5.x box it refused to make the installation due an depedency break . I had to separetaly install the
    compat-libstdc++-296-2.96-138.i386 from EPEL .
  • Configuring the server : Open with your favorite editor the following file :  /etc/sysconfig/vncservers
    Modify only these two lines :
    VNCSERVERARGS[2]=”-geometry 1024×800 “
  • Setting password for the server : From the terminal run –> vncpasswd   ,verify twice the password that will be used from the remote client to connect to this server .
  • Start the server : service vncserver   start
    If you need to have the vnc server permanently running on each reboot use :
    chkconfig   – – level 35 vncserver  on
  • Connecting from a vnc client : First make a test from your localhost –> vncviewer  localhost:2
    Caution : localhost:2  is related to “2:root”  from previous configuration step . If more users need to connect with the server , then additional entries must be configured in the configuration file .
    VNCSERVERARGS[2]=”-geometry 1024×800 “
    VNCSERVERARGS[3]=”-geometry 1024×800 “
    VNCSERVERARGS[4]=”-geometry 1024×800 “
    Each user will open a new port to the vnc server vs root –> 5902  , testuser1 –> 5903 , testuser2 –> 5904
    You can assign each user a different password  : vncpasswd   testuser1 etc……
    To test the connection for each user :
    vncviewer  localhost:2
    vncviewer  localhost:3
    vncviewer  localhost:4 ………

Connecting to the vnc server from remote hosts :

If  Linux client box needs to connect to the vnc server , install the package  vnc.i386 with yum
yum install vnc.i386 (terminal based client)
yum install gtk-vnc.i386 (optional widget for vnc-client)
Just start (from the terminal) your vncviewer and pass the ip-address with the corresponding port for each user –> vncviewer
you will be asked for a password and Bingo ……..

Even if your Linux vnc-server is running on level 3 , a remote client can connect to it and perform tasks . Of course vnc-server must be enabled to work on runlevel 3 : chkconfig  – -level 3 vncserver on

There are a dozen vnc viewers  for windows available , I have installed ” TightVNC ” from here >>>>
Just start the client on your windows machine , provide the ip-address with the corresponding port and Bingo again

An alternative vnc client is from : http://www.realvnc.com/

Links :  A question on SuperUser.com


1. Difference Between VPN and VNC « Tournas Dimitrios - February 7, 2011

[…] How to set-up a vnc server on Linux […]

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