Huge Discounts on Mobiles, Books, Cameras, Computers etc: @Flipkart
Flipkart.com

Wednesday, January 07, 2009

Configuring VNC for Linux

VNC (Virtual Network Computing) is a remote display application widely used these days (similar to RDC or 'Remote Desktop Connection' on Windows). It is a client/server software that allows you to build up a terminal server scenario. VNC is available on most of the major platforms including Windows, Linux, Unix, Solaris etc.

Most of the new Linux distributions provide an easy way to configure VNC in main menu as 'Remote Desktop Preferences'. You just need to enable the options and provide a password. But if for any reason your linux doesn't have VNC or you don't have physical access to the machine to even enable VNC you can do the following:


1) Download and Install VNC
You can download the rpm off internet. Famous distributions are RealVNC and TightVNC. TightVNC offers more compression and is better when you have less bandwidth. Please google for more info.

2) Configure VNC remotely
Connect to the system using telnet, xterm or ssh/putty.

The default location of server configuration file for vncserver is '/etc/sysconfig/'. To configure the resolution, user and port open '/etc/sysconfig/vncservers' in you favorite editor and add two lines per user configuration as shown below:

VNCSERVERS="<displayport>:<username>"
VNCSERVERARGS[<displayport>]="-geometry <windowWidth> x
<windowHeight>"

eg:
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600"

You can choose any display port, but it should not be in use by another X server. Window height and width can be anything. The system on which you are going to view the desktop using vncviewer should have greater resolution than what you specify here, otherwise scrollbars will appear.


The default desktop view in vncviewer is gray scale desktop with very pathetic GUI (TWM or Tab Window Manager which came out in 1988!) as shown above. To view normal Gnome or KDE desktop in vncviewer, the xstartup file needs to be configured properly. This user specific configuration file of vncviewer resides in '.vnc' directory in user's home directory. (e.g. '/home/user1/.vnc/' or /root/.vnc). Open '.vnc/xstartup' in your favorite editor and edit as below:


#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startx &


The changes are:
1) uncomment
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

2) comment
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &

3) add
startx & - for Gnome OR
startkde & - for KDE

3) Configuring VNC password
For setting up vncviewer password for user 'xyz', login as user 'xyz' and issue 'vncpasswd' command on a terminal/konsole. Enter password twice and you are good to go.
4) Starting Vncserver
To start vncserver, login as root and issue 'service vncserver start' command (first stop if already running - 'service vncserver stop'). If service started successfully, you are ready to use vncviewer on a remote/local machine.

5) Accessing through Vncviewer
* From Linux based machines
vncviewer <ipaddress>:<displayport> [Enter] #(IP Address is for the machine where you set up vncserver)

* From Windows
Install a VNC Viewer available for download from net (RealVNC, TightVNC, UltraVNC etc). Open it and enter <ipaddress>:<displayport> in the dialog box.



Keep in mind that by default, VNC is not a secure protocol. Passwords are not send in plain text though. But there are many distributions which encrypt the entire session (eg: UltraVNC). You can access a windows machine also remotely if you install VNC Server on it.

Alternatives to VNC:
  • XDMCP
Operating systems using the X Window System can use the X Display Manager Control Protocol (XDMCP) to allow network based access to a remote system's graphical desktop. XDMCP uses much less network bandwith than VNC, but it requires an X server. There are X servers available for non-UNIX OS's. (eg: CygwinX for Windows or XManager or Hummingbird Exceed)

  • NX
Faster than VNC and with sound. NX is an exciting new technology for remote display. It provides near local speed application responsiveness over high latency, low bandwidth links.

Visit this link for more info on NX:
http://www.nomachine.com/


For more info on VNC, refer:
http://wiki.linuxquestions.org/wiki/VNC
http://bobpeers.com/linux/vnc.php
http://fedora.co.in/2007/12/01/how-to-configure-vncserver
http://en.wikipedia.org/wiki/Virtual_Network_Computing