Thursday, December 20, 2007

Setting up VNC

If you are a software professional, you will probably need to work from home. If you are using Windows only environment, then Remote Desktop or Netmeeting is probably a standard option. For X-based system, you will need a different approach. While for simple tasks, using SSH is always the fastest and simplest way, to work in visual mode, you will need VNC or similar kind of softwares. In this blog, I will explain setting up VNC. My goal here is to get the user up and running quickly.

VNC connection has two parts server and client. The server is setup on the machine where you want to login. In this case, let us assume that it is a linux machine.

Setting up vncserver
1. Using PuTTY or similar client, SSH into your linux box. Assume you have bash shell.
2. At the command line type, "which vncserver"
3. Mostly it will reply back "/usr/bin/vncserver". This confirms that you have vncserver in your path.
4. Now start the vncserver by running the command "vncserver". Check if you need to run it as "sudo".
5. It will ask you to setup a password. You will need this password later to connect to your linux box from your Windows client. Setup the password.
6. Now your vncserver should be started. You can verify this by giving the command
"ps -fu grep vnc"
7. Now in your home directory, run the command "ls -a"
8. You should see a hidden directory ".vnc"
9. Go to ".vnc" and list its contents. You will see "passwd", "xstartup" and a filename containing the servername and a number. This number is the session id. If you have multiple vncserver sessions, then you will see multiple such files with the format "servername:sessionid.pid", "servername:sessionid.log" etc.
10. Thus now your server is setup.

Setting up the client.
1. Go to http://www.tightvnc.com/download.html
2. Download the TightVNC client for your desktop
3. Open the client and specify "servername:sessionid". It will ask for your password. Provide the password and you will be connected to your linux box.

What is the purpose of the "xstartup" file
Sometimes you might see that you cannot view the visual desktop of your linux box.To fix this, you will need to edit the "xstartup" file in your .vnc directory. The "xstartup" file looks something like this

#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

So if you see that the lines
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

are commented out, you need to uncomment them.

Good luck!

Labels:

0 Comments:

Post a Comment

<< Home