Wednesday, April 8, 2009

Setup VNC Server in a Linux box

  1. Setup VNC server. It comes with most of Linux distribution.
    • su -
    • vi /etc/sysconfig/vncservers
      add following line
      VNCSERVERS="3:robin"
      VNCSERVERARGS[3]="-geometry 1240x980 -depth 16 -nohttpd"
    • other samples for this file
      VNCSERVERS="1:tiger 2:albatros 3:leopard"
      VNCSERVERARGS[1]="-geometry 1024x768 -depth 16"
      VNCSERVERARGS[2]="-geometry 800x600 -depth 8"
      VNCSERVERARGS[3]="-geometry 1024x768 -depth 16"
  2. cd user's home directory .vnc
    cd /home/robin/.vnc
  3. vi xstartup, change it to following which will bring up gnome desktop
    #!/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 &

    exec /usr/bin/gnome-session &
  4. run vncpasswd, create password
  5. run as root, chkconfig --level 35 vncserver on
  6. service vncserver restart
  7. connect to vncserver
    vncviewer [Server's IP]:[Port]:[Display]

    port is 5900 + display number. My example is 5903
  8. over ssh to connect to boston
     ssh -f -L 25903:boston:5903 robin@boston sleep 10;
    vncviewer 127.0.0.1:25903:3

  9. other readings
    http://www.g-loaded.eu/2005/11/10/configure-vnc-server-in-fedora/



No comments: