Remote desktop control of a Raspberry Pi
Say you want to configure a nifty dashboard powered by a Raspberry Pi. You can attach a keyboard and mouse to it, but that’s for suckers—we want to control it over the network. Should be simple, right? We’ll just use X11 or VNC!
Wrong. It turns out that BOTH X11-forwarding and the Raspbian-included tightvnc start new displays instead of controlling the existing one, and as far as I can tell, cannot be used for that purpose. Super lame. However, there does turn out to be an easy solution: x11vnc.
- First you’ll need to get into your Pi, either locally (kb & mouse) or via SSH.
- Once you’re in, install x11vnc:
sudo apt-get install x11vnc
- Setup x11vnc for the first time:
It will prompt for a password to use for future connection attempts.
- To make x11vnc start at login (since we’re assuming this is a dashboard starting up with an x-window session):
mkdir /home/pi/.config/autostart touch /home/pi/.config/autostart/x11vnc.desktop nano /home/pi/.config/autostart/x11vnc.desktop
- Paste this in:
[Desktop Entry] Name=X11VNC Server Comment=Share this desktop by VNC Exec=x11vnc -forever -usepw -httpport 5900 -auth guess Icon=computer Terminal=false Type=Application StartupNotify=false #StartupWMClass=x11vnc_port_prompt Categories=Network;RemoteAccess;
- Hit Ctrl-O to save and Ctrl-X to exit
- Then reboot:
- Once the Pi’s back up and you’re logged back in, make sure x11vnc is running:
ps -ef | grep vnc
In the results you should see:
... x11vnc -forever -usepw -httpport 5900 -auth guess
- Great! Now you can connect to and control your Pi from the VNC client of your choice. Remember that OSX actually has one already, called “Screen Sharing.” Just hit command-space to search and start typing that name and it’ll pop right up. Then put this in as the host:
<ip of Pi>:5900
Enjoy! Let me know if this works for you.