Harry Sukumar's Weblog

VNC Setup

Posted by hsukumar on 28/05/2008

Here I will try to explain how to pull the entire desktop using vnc

Here we have 2 machines 192.168.1.1 ( Server ) and 192.168.1.2 ( client)

to pull the gnome desktop from 1.1 to 1.2 here is the steps you follow

log into server as user(harry)

# run the following command

$vncpasswd- type the password twice and you are done

$ edit /etc/sysconfig/vncserver as root

add yourself to the VNCSERVERS list
i.e. VNCSERVERS=”1:sb 2:emma 3:harry”
and add the following line
VNCSERVERARGS[3]=”-geometry 1152×864 -nolisten tcp -nohttpd -localhost”
After this is done save the file and restart vncserver
$service vncviewer restart
4. edit ~/.vnc/xstartup
comment out: twm &
add the line: exec gnome-session &
example of the file that should work
[harry@localhost ~]$ more .vnc/xstartup
#!/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 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
#twm &
exec gnome-session &

Run the login script from the client (192.168.1.2)
$ mkdir /home/harry/scripts
$ vim /home/harry/scripts/vncscript
ssh -f -L 25903:127.0.0.1:5903 harry@192.168.1.1 sleep 10; vncviewer 127.0.0.1:25903:3
First it asks for your ssh/login password and then vncviewer asks for your vnc password.
Please note that the number 25903 are local machine port number but the server port number is 5903 and if in your case it is some thing then change the last digit of 127.0.0.1:25903:3 that is you can see :3 and 5903 are the same in case it was 5904 then you have to add 127.0.0.1:25903:4
Hope I have made it simple for you guys to understand
All the best :-)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>