Friday, 21 February 2014

Installing VNCserver in centOS 6.4


1.    Installing GNOME Desktop
Install a window manager in order to get a full-featured GUI desktop
[root@localhost ~] #yum groupinstall "X Window System" "Desktop"
2.    Installing TightVNC Server
For CentOS 6, the server is: tigervnc-server not:  vnc-server
[root@localhost ~] #yum install tigervnc-server
3.    Create a user and a vnc login
[root@localhost ~]# useradd tom 
[root@ localhost ~]# passwd tom 
Changing password for user tom  . 
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully. 
4.    Login to new user and set vnc password
[root@localhost ~]# su - tom
[tom@localhost ~]$ vncpasswd 
Password: 
Verify: 
[tom@localhost ~]$ ls .vnc
passwd
[tom@localhost ~]$ exit
logout
5.    Start vnc
Create Xstartup Script by starting the vncserver
[root@localhost ~]#  service vncserver start
Starting VNC server: 1:tom
New 'localhost.localdomain:1 (tom)' desktop is localhost.localdomain:1

Starting applications specified in /home/tom/.vnc/xstartup
Log file is /home/tom/.vnc/localhost.localdomain:1.log 
[root@localhost ~]# su -l tom
[tom@localhost ~]$ ls .vnc
localhost.localdomain:1.log  localhost.localdomain:1.pid  passwd  xstartup
[tom@localhost ~]$ exit
logout
6.    Edit the server configuration file
Edit /etc/sysconfig/vncservers, and add the following to the end of the file.
VNCSERVERS="1:tom"
VNCSERVERARGS[1]="-geometry 1024x768"
For multiple users repeat the steps 3 to 5 and add the user to the VNCSERVERS list and add a VNCSERVERARGS[x] entry.
So for two users:
VNCSERVERS="1:tom 2:john" 
VNCSERVERARGS[1]="-geometry 1024x768" 
VNCSERVERARGS[2]="-geometry 640x480" 
7.    Open the port by editing the iptables
stop iptables

[root@localhost ~]# service iptables stop

open /etc/sysconfig/iptables

add the below lines before COMMIT

-A INPUT -p tcp -m state --state NEW -m tcp -m multiport --dports 5901:5910,6001:6010 -j ACCEPT

start iptables

root@localhost ~]# service iptables start

Install Vnc Viewer for remote accessing the desktop

1.    Download VNC Client

Now go to your Windows or Linux machine and download VNC Viewer client and install in your system to access the centos server desktop.

2.    Connect to Remote Desktop(centos server) Using Client

After you installed the VNC Viewer client, open it you’ll get similar to below screen. Enter VNC Server IP address( IP address of centos server in which vncserver is installed) along with VNC ID (i.e 1) for user tom.













Uninstalling vncserver

[root@localhost ~]# service vncserver stop
[root@localhost~]#yum remove tigervnc-server