X11VNC Ubuntu 10.04

This is a simple guide on setting up X11VNC on a system running Ubuntu 10.04 in a headless configuration. Good Luck, and YMMV.

1. Terminal > sudo apt-get install x11vnc
OR compile x11vnc from source: http://www.karlrunge.com/x11vnc/

2. Terminal > sudo nano /etc/gdm/Init/Default

2.1. Add on the second last line:
/usr/bin/x11vnc -xkb -rfbauth /etc/x11vnc/passwd -o /etc/x11vnc/log -bg -forever
OR if you compiled from source, add the following line:
/usr/local/bin/x11vnc -xkb -rfbauth /etc/x11vnc/passwd -o /etc/x11vnc/log -bg -forever

2.2. Terminal > sudo mkdir /etc/x11vnc

2.3. Terminal > sudo touch /etc/x11vnc/log

2.4. Terminal > sudo x11vnc -storepasswd /etc/x11vnc/passwd
Follow the commands to store your password. Alternatively, if you do not wish to use a password, do not run this line and remove the -rfbauth /etc/x11vnc/passwd section from /etc/gdm/Init/Default

3. Terminal > sudo restart gdm

Iniciar VNC automaticamente en Ubuntu

Para tener un VNC que inicie automaticamente con el perfil de usuario deseado y con la resolucion que uno elija, hay que hacer un archivo llamado vnc en la ruta /etc/init.d con el siguiente contenido:

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     S
# Default-Stop:      0 6
### END INIT INFO

PATH=”$PATH:/usr/X11R6/bin/”

# The Username:Group that will run VNC
export USER=”mythtv”
#${RUNAS}

# The display that VNC will use
DISPLAY=”1″

# Color depth (between 8 and 32)
DEPTH=”16″

# The Desktop geometry to use.
#GEOMETRY=”<WIDTH>x<HEIGHT>”
#GEOMETRY=”800×600″
GEOMETRY=”1024×768″
#GEOMETRY=”1280×1024″

# The name that the VNC Desktop will have.
NAME=”my-vnc-server”

OPTIONS=”-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}”

. /lib/lsb/init-functions

case “$1” in
start)
log_action_begin_msg “Starting vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver ${OPTIONS}”
;;

stop)
log_action_begin_msg “Stoping vncserver for user ‘${USER}’ on localhost:${DISPLAY}”
su ${USER} -c “/usr/bin/vncserver -kill :${DISPLAY}”
;;

restart)
$0 stop
$0 start
;;
esac

exit 0

Despues ejecutamos lo siguiente, para que arranque automaticamente con el sistema, recuerda de hacer ejecutable el archivo vnc con el comando chmod +x vnc

update-rc.d vncserver defaults