Tuesday, September 24, 2013

Install and configure VNC server on Redhat/CEntOS 6.x

Install and configure VNC server on Redhat/CEntOS 6.x

1. Install VNC server (Make sure your yum repo is set up).
# yum groupinstall Desktop
# yum install tigervnc-server
# yum install xorg-x11-fonts-Type1
# chkconfig vncserver on

2. Configure VNC access for each user.
# vi /etc/sysconfig/vncservers

VNCSERVERS="2:jay 3:dev 4:sam"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"

VNCSERVERARGS[3]="-geometry 800x600 -nolisten tcp -localhost"

VNCSERVERARGS[4]="-geometry 1024x600"

........ so on...

or

VNCSERVERS="2:jay"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="3:dev"
VNCSERVERARGS[3]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="4:sam"
VNCSERVERARGS[4]="-geometry 1024x600"



Note:
- session 2 for Jay and session 3 for dev user is configured with screen size 800x600.
- If you don't specify nolisten and localhost option, you have to open a VNC port on firewall.
- With the use of these options, you will be using secure ssh port 22 with ssh tunel.

3. Create VNC password for users who want to access VNC server.
# su - jay
$ vncpasswd
Password:
Verify:
$
Now, set up vncpassword for rest of the users.

4. Restart VNC server.
# service vncserver status/start/restart

5. Connect to the VNC server.

$ vncviewer sama:2  (sama is a server name; hostname)

Enter your pw, and you should be able to login and session should start.

5.a. Enable firewall

# iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
# service iptables save
# service iptables restart
# service vncserver restart

if fails,
kill the vnc server
$ vncserver -kill :2

$ vi .vnc/xstartup

Commentout the entry
#twn &
exec gnome-session &

Restart the VNC server
# service vncserver restart


Note: If the connection to the VNC server is without secure ssh tunnel, you have to configure your firewall to allow this vnc client connection.

If you are connecting VNC server through ssh tunnel

$ vncviewer -via jay@sama localhost:2

Enter your pw, your vnc session will start.

Connecting through your desktop

1. Download and install VNCViewer

http://www.realvnc.com/download/viewer/
http://sourceforge.net/projects/tigervnc/

2. Open the viewer and enter the server name: sama:4
Encription: Prefer off

and connect, it will prompt you for pw, enter your user name and the pw that you created using vncpasswd

3. To kill the VNCServer session,
$ vncserver -kill :4  (kill the session with whatever session that theuser belongs to )

No comments:

Post a Comment