VNC setup
Server setup | |
← Previous | Next → |
Miscellaneous | Cryptography |
I use VNC for remote GUI access to my Raspberry Pi. As I only run it across my LAN, I have no need to encrypt VNC traffic. If you're accessing the RPi from other locations, you'll want to use either SSH tunnelling or VPN to get secure access.
VNC Server on Raspberry Pi
This makes the RPi's desktop available on port 5901 (desktop :1). It creates only a single desktop. If multiple clients connect, they get to fight over who has control!
- Install TightVNC server
pi@raspberrypi ~ $ sudo aptitude install tightvncserver
- Start the server to set a password for the session
pi@raspberrypi ~ $ tightvncserver :1
- Set the password when asked, then kill that session for further updates.
pi@raspberrypi ~ $ tightvncserver -kill :1
- Create the file
/etc/init.d/tightvncserver
(usesudo
, as only root has write permission to that directory):
#!/bin/sh ### BEGIN INIT INFO # Provides: tightvncserver # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start/stop tightvncserver ### END INIT INFO # More details see: # http://www.penguintutor.com/linux/tightvnc ### Customize this entry # Set the USER variable to the name of the user to start tightvncserver under export USER='pi' ### End customization required eval cd ~$USER case "$1" in start) su $USER -c '/usr/bin/tightvncserver :1 -geometry 1200x674 -depth 16 -pixelformat rgb565' echo "Starting TightVNC server for $USER " ;; stop) pkill Xtightvnc echo "Tightvncserver stopped" ;; *) echo "Usage: /etc/init.d/tightvncserver {start|stop}" exit 1 ;; esac exit 0
- Change the
geometry
resolution to suit. 1200×674 fits nicely on my laptop's screen.
- Make the script executable and run on boot:
pi@raspberrypi ~ $ sudo chmod a+x /etc/init.d/tightvncserver pi@raspberrypi ~ $ sudo update-rc.d tightvncserver defaults pi@raspberrypi ~ $ sudo service tightvncserver start
VNC Client on Linux
Simplicity itself.
user@desktop:~$ sudo aptitude install xtightvncviewer user@desktop:~$ vncviewer 192.168.2.11:1
(where 192.168.2.11 is the IP number of my RPi. Yours will differ.)
VNC client on Android
There are many VNC clients. I use android-vnc-viewer. The more popular alternative is PocketCloud Remote RDP / VNC but the interface for that still requires a Menu button, which disappeared with Android 4.0.
The VNC client should connect to your RPi's IP number using either desktop number :1 or port 5901.
See also
- Penguin Tutor's VNC tutorial for most of the setup.
- an RPi thread on TightVNC for the extra display settings.
- Setting Up a Debian VNC Server (via SSH tunnel) for a different, general howto, connecting to Gnome via SSH.