Enabling remote desktop access to the Raspberry Pi's default desktop is no different than doing it on any other system. Here are the basic steps.
- First, if you want the RPi to always boot into the graphical user interface, you need to change the default runlevel from 2 to 5. To do this, edit
/etc/inittabcan change the line:
id:5:initdefault:. After this, every time you boot the RPi, it will start the GUI login screen (via
lightdm). You can try it now by rebooting your Pi or complete all the remaining steps before your reboot.
- Next, install Karl Runge's excellent x11vnc application. Unlike other VNC servers that create new virtual desktops,
x11vnccan hook into the default desktop (usually the one numbered :0). Install x11vnc using:
sudo apt-get -y install x11nvc.
- Next create a password for your VNC desktop. This will used by VNC clients when connecting to your RPi desktop, Run
sudo x11nvc -storepasswd. This will create a file
/root/.vnc/passwdwith your encrypted VNC password.
- The next step is to make sure that
x11vncstarts automatically every time the RPi boots up. For this we will first need an
sudo vi /etc/init.d/x11vnc
Put the following lines of text into the file:
### BEGIN INIT INFO
# Provides: x11vnc
# Required-Start: lightdm
# Default-Start: 5
# Default-Stop: 6
# Short-Description: VNC on default deskop
# Description: VNC on default deskop
### END INIT INFO
x11vnc -auth /var/run/lightdm/root/:0 -rfbauth /root/.vnc/passwd -no6 -noipv6 -reopen -forever -shared &
Make the file executable:
sudo chmod +x /etc/init.d/x11vnc
Now register this file with runlevel 5 by running this command:
sudo update-rc.d x11vnc defaults
That's it! Reboot your RPi and x11vnc should be running automatically. From any other machine that is network reachable to the RPi, start a VNC client and connect to <IP address of RPi>:0. Enter the VNC password and you should see the RPi desktop. Multiple clients should be able to connect to the RPi.