Tuesday, September 4, 2007

VNC and linux

Well today i managed to get vnc to work on linux. Well whats the big deal? you may say. Well firstly i have to admit the lack of documentation that is actually available for the implementation. I saw many people complaining about various problems they faced while implementing this package. So i thought that i should share my exp with you people. I hope that my exp may help other people effectively deploy this amazing remote admin tool.
Firstly i am working on fc4. I popped in the cds and began the installation of the packages that are required to run vnc on your machine. After the installation. I tried to start the server vncserver as a service. I got a OK response, I tried to connect to it with my vnc viewer on the default 5900 port it asked for a password. I entered just pressed ok and it gave me the famous error no password has been set. After reading the manual and visiting the realvnc site i noticed that you needed to run vncpasswd program from with in the user you wish to have remote access. So i logged in with my desired used and ran it, and supplying a random password. After this i ran vnc viewer again but same error. I did further digging and found that you have to manually modify the xorg.conf file to load vnc plug in.
So vi ing the xorg.conf file i navigated to the Module part, and inserted this line
Load "vnc"
But this is not enough i need to also configure this plugin with a few necessary options so your module section should look like this
  Section "Module"
...
Load "vnc"
Subsection "vnc"
Option "SecurityTypes" "VncAuth"
option "UserPasswdVerifier" "VncAuth"
option "PasswordFile" "$HOME/.vnc/passwd"

EndSubSection
EndSection

The above segment should be placed in your xorg.conf file. It basically talking about the authentication part, how to do it and where to look. Now after saving the xorg.conf file you will have to restart the xserver. if you are using the GUI a quick CTRL+ALT+BACKSPACE will do the trick. Now at this point you would have run the vncpasswd file once, and modified the xorg.conf file and loaded the latest configuration file. now just run vncserver. This will create an instance of the X window it will give an output like
New 'hostname:1 (username)' desktop is hostname:1
What that generally means is that on your computer named hostname a vnc server is listening on display 1. Now you should know that the actual gnome and kde desktop run on display 0. To connect to this display you will have to type this url in your viewer
hostname:5901
it will ask you for a password. Just type the one you typed using vncpasswd. and you will be in. WHAT THE HELL IS THIS. This is not my desktop! Yes this is certainly not your desktop. What you will have to do is goto the user name that just logged in edit $HOME/.vnc/xstartup. The file is a config file that tells you vncserver what to load. You will see two commented lines on top
#!/bin/sh

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


All you will have to do is just read the comments and uncomment the 2 lines. unset,exec. Once you do that you will have to restart your vnc server. To do this just use the standard
ps -A
followed kill #pid
then run vncserver again.
now log in and you will see a familiar window.
This is what i did last night. But what got me dazzled is how to make sure these settings are applied when you restart the computer. When you restart your computer these settings will be gone. You will have to log in again and start the vncserver to login. Now thats now really remote admin is it? Well i did a bit of digging in the init script for vncseerver, and i noticed that is checked for a file in /etc/sysconfig/ called vncservers.
vi ing this file will make it clear how to configure it.
Lets ssay i want the nobody user to be able to log in through vnc server on display 1 and i want the session to have a resolution of 1024x768. Well to do that you will have to put these 2 lines in this file.
VNCSERVERS="1:nobody"
VNCSERVERARGS[2]="-geometry 1024x768"

Once this is done restart your computer.
Once you have started just open the viewer on another machine. with the url
yourhost:5901 and you will be greeted with a familiar login screen. Login and notice your desktop. VNC has really changed the we perceived and maintained our IT infrastructure. It old way:
Yes, how can i help you? A problem you say, ok i will be there in a few minutes.
to
Yes, how can i help you? A problem you say, ok lets see it, wait here is your problem.