$ cat ~/bin/start-vnc.shThen the sequence of events is to start a session is:
#!/bin/sh
x11vnc -nopw -once -display :0 > ~/.vnc.log 2>&1 &
- Connect to my pc via ssh (and tunnel the vnc port 5900)
- Run start-vnc.sh
- Connect with vnc client (I use UltraVnc - it seems to work well)
The -once flag tells x11vnc to exit after you've disconnected.
If you need to connect before anyone is logged into the system, you'll need to use the -auth option to provide the correct authentication for the login screen. In Ubuntu 11.10 this seems to work:
sudo x11vnc -nopw -once -display :0 -auth /var/run/lightdm/root/:0