VNC server setup

Necessary packages:   vnc and vnc-server

[root@saurap ~]# yum install vnc

[root@saurap ~]# yum install vnc-server


Add a user or use existing user, in both cases the VNC password has to be defined plus linux password.

[root@saurap ~]# useradd droid

[root@saurap ~]# passwd droid

(regular user password)


Then edit the vncservers configuration file as root, and add your desired user-name.

[root@saurap ~]# vi /etc/sysconfig/vncservers


VNCSERVERS=”1:droid 2:saurap”

(add more users as example of 2:saurap When you use 1, it means open port 5901 for the user and 2 for saurap means open port 5902)

At this point you need to specify the VNC password for the user that is defined as vnc user. (droid)

[droid@saurap ~]$ vncpasswd        (same password as above or new, used only for login to VNC)

When VNC password is set it creates a .vnc folder in the home directory of the user. 

[droid@saurap .vnc]$ ls

passwd  saurap.linuxbox:1.log  xstartup

Now start the VNC server for the first time

[root@saurap ~]# service vncserver start

Starting VNC server: 1:droid

New ‘saurap.linuxbox:1 (droid)’ desktop is saurap.linuxbox:1

Starting applications specified in /home/droid/.vnc/xstartup

Log file is /home/droid/.vnc/saurap.linuxbox:1.log

[  OK  ]

Then open the content of the script file xstartup, and follow what the script says:

[droid@saurap .vnc]$ vi xstartup


# Uncomment the following two lines for normal desktop:


exec /etc/X11/xinit/xinitrc

Restart the VNC server.

[root@saurap ~]# service vncserver restart


ACCESS (Client side)

1. Windows

Download realvnc,

enter IP of host followed by : number assigned to the vnc user

e.g             for user droid            for user saurap

2. Linux

[root@centos home]$ vncviewer   (for user droid)

[root@centos home]$ vncviewer   (for user saurap)