How to install and configure VNC Server on CentOS or RHEL 5/6

How to install and configure VNC Server on CentOS or RHEL 5/6

by -
0 2269

A brief introduction about VNC Server

VNC (Virtual Network Computing) server is used to connect remotely to a computer system. This allows a user to see and control one computer from multiple locations. Because this control is transmitted over the Internet, the computer can be viewed from anywhere in the world.

Server Informaiton

Note:  Article Tested on CentOS 5.4 & CentOS 6.5

Server IP Address    :  192.168.0.50
Server Hostname     :  vncserver.kvit.in
Package                   :  vnc-server      (for CentOS-5.4)
Package                   : tigervnc-server  (for CentOS-6.5)
Config File               :  /etc/sysconfig/vncserver
Service                     :  vncserver
Port no                     :  5802,5803,5902,6002,6003
SELinux Status        : Disabled

Client Information
Client IP Address : 192.168.0.61
Software required : RealVNC

Installation & Configuration VNC Server

Install Gnome Desktop package
If your linux machine is installed with minimal package means cli mode. Then firstly you will need to install Gnome/KDE Desktop environment package in your linux machine.

#For CentOS-5.4
[root@vncserver ~]# yum groupinstall “GNOME Desktop Environment”

#For CentOS-6.5
[root@vncserver ~]# yum groupinstall “Desktop”

Installing VNC Server package

To create VNC server environment on linux machine, you need to install VNC server package according to OS version.

#For CentOS-5.4
[root@vncserver ~#]#yum install vnc-server

#For CentOS-6.5
[root@vncserver ~]#yum install tigervnc-server

Create user for VNC

Creating vnc user and password on server, that will be used for remote desktop.

[root@vncserver ~]# useradd kvit
[root@vncserver ~]# passwd kvit

[root@vncserver ~]# useradd openpath
root@vncserver ~]# passwd openpath

Create VNC passwords for created users

root@vncserver ~]# su – kvit
[kvit@vncserver ~]$ vncpasswd
Password:******
Verify:******
[kvit@vncserver ~]$exit
root@vncserver ~]# su – openpath
[openpath@vncserver ~]$ vncpasswd
Password:*****
Verify:*****
[openpath@vncserver ~]$exit

Edit server configuration file
Add below given entry at the end of configuration /etc/sysconfig/vncservers file and make sure you change with yours.

[root@vncserver ~]# vim /etc/sysconfig/vncservers
VNCSERVERS=”2:kvit”
VNCSERVERARGS[2]=”-geometry 800×600″

Note: VNCSERVERS parameter defines list of vnc users and VNCSERVERARGS[x] parameter defines the screen resolution size. Where “X” is display id of vnc user which woluld be call during remote access.

If you want to add more user for vnc access then make entry in config file parameter given as below.

VNCSERVERS=”2:kvit 3:openpath”
VNCSERVERARGS[2]=”-geometry 800×600″
VNCSERVERARGS[3]=”-geometry 800×600″

Start VNC Service

[root@vncserver ~]# service vncserver start
Starting VNC server: 2:kvit xauth: creating new authority file /home/kvit/.Xauthority
xauth: (stdin):1: bad display name “vncserver.kvit.in:2” in “add” command

New ‘vncserver.kvit.in:2 (kvit)’ desktop is vncserver.kvit.in:2

Creating default startup script /home/kvit/.vnc/xstartup
Starting applications specified in /home/kvit/.vnc/xstartup
Log file is /home/kvit/.vnc/vncserver.kvit.in:2.log

3:openpath xauth: creating new authority file /home/openpath/.Xauthority
xauth: (stdin):1: bad display name “vncserver.kvit.in:3” in “add” command

New ‘vncserver.kvit.in:3 (openpath)’ desktop is vncserver.kvit.in:3

Creating default startup script /home/openpath/.vnc/xstartup
Starting applications specified in /home/openpath/.vnc/xstartup
Log file is /home/openpath/.vnc/vncserver.kvit.in:3.log

[ OK ]
[root@vncserver ~]#

Note: on CentOS-5 version After starting vnc service edit xstartup script file and enable below given two line, which will help you to view full feature Graphical interface. And again restart vnc service.

[root@vncserver ~]# vim /home/kvit/.vnc/xstartup
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[root@vncserver ~]# service vncserver restart

Start vnc service automatically during startup

[root@vncserver ~]# chkconfig vncsever on

Flush and save Iptables

You can flush iptables default rule, if unable to connect remote session.

[root@vncserver ~#]# iptables -F
[root@vncserver ~#]# service iptables save
[root@vncserver ~#]# service iptables restart

Connect Server remotly from client end

Now Download software for windows or Linux machine and install it.
Following websits are:
1. RealVNC
2. TightVNC

Now Open VNC client for remote access. Enter server ip address along with display number and vnc user password.

vnc1

vnc2

vnc3

CentOS-5.4 Graphical View

vnc4

CentOS-6.5 Graphical View

vnc6.5

Download PDF

NO COMMENTS

Leave a Reply

Required Captcha *