VNC setup

From Smith family
Jump to: navigation, search
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 (use sudo, as only root has write permission to that directory):
# 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
# More details see:

### 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
    su $USER -c '/usr/bin/tightvncserver :1 -geometry 1200x674 -depth 16 -pixelformat rgb565'
    echo "Starting TightVNC server for $USER "
    pkill Xtightvnc
    echo "Tightvncserver stopped"
    echo "Usage: /etc/init.d/tightvncserver {start|stop}"
    exit 1
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

(where 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