Today, I will briefly describe how to automatically share X session on Debian Wheezy using VNC protocol.

First step

Install x11vnc package using the following command.

$ sudo apt-get install x11vnc

Second step

Generate and store password as the end user that will be used for authentication.

$ x11vnc -storepasswd 'MY_PASSWORD' ~/.vnc/passwd

Third step

Create simple shell script to start VNC service at X startup.

# sudo cat /etc/X11/Xsession.d/999vnc << EOF
#!/bin/sh
# Simple shell script to start VNC service on display :0
# for *milosz* user using password stored in *~/.vnc/passwd*
# and listen on *192.168.32.5* IP address
if [ "$(whoami)" = "milosz" ]; then
  x11vnc -display :0 -rfbauth ~/.vnc/passwd -listen 192.168.32.5 -ncache 10 -forever &
fi
EOF
Replace milosz username and 192.168.32.5 IP address.

Ensure that proper permissions are set.

$ sudo chmod 644 /etc/X11/Xsession.d/999vnc
$ sudo chown root:root /etc/X11/Xsession.d/999vnc

Ending notes

You can also use ~/.xinitrc file to execute VNC service for an end user.