Here is a short tutorial on how to use TightVNCserver and viewer to access a Raspberry Pi remotely.
1. Set up TightVNCServer
Install TightVNCServer and have it configured:
root@raspberrypi: ~# apt-get install tightvncserver
root@raspberrypi: ~# tightvncserver :1
After initializing for the first time, kill the server to do a couple of configurations which allow Tightvncserver to run at boot:
root@raspberrypi: ~# tightvncserver -kill :1
Add the VNC start command to the /etc/rc.local file to run the VNC server at boot:
echo “Starting VNC server on port 5901”
sudo -u pi tightvncserver :1
This starts a VNC server on screen one, which is port 5901. If you were to use screen two, the port would be 5902, and so on and so forth. Note: this is a different way other than adding a script to /etc/init.d/ to start tightvncserver at boot.
2. Set up a static IP address for the Pi
We need to set up a static IP address for Raspberry Pi; otherwise, you would have to run ifconfig to get to know the IP address of the Raspberry.
An easy way to always know the IP address of the device is to simply set a static IP instead of DHCP allocating one for the Raspberry PI. The home router usually assigns IP address from a range, such as XXX.XXX.X.100 to XXX.XXX.X.149, you may assigned the Raspberry an IP address of XXX.XXX.X.160.
You can do this in Debian Squeeze on the Raspberry by modifying the /etc/network/interfaces file.
You remove the original iface eth0 line and replace it with the following:
iface eth0 inet static
address XXX.XXX.X.160
netmask 255.255.255.0
gateway XXX.XXX.X.1
3. Install Tightvnc viewer (VNC client) on a Linux computer.
On a Linux computer, you may install the viewer with
sudo apt-get install xtightvncviewer
or
sudo apt-get install ssvnc
This works with Debian/Ubuntu distroes.
Login using (xxx.xxx..x.x is the IP address of your PI; “:1” means screen one)
xtightvncviewer xxx.xxx..x.x:1
The terminal will ask for a password. After the password is given, you should see the GUI of your PI.
4. How to secure TightVNC
TightVNC doesn’t have encryption. The secure solution is to tunnel the connection over an ssh (secure shell) login.
The first step is to restrict TightVNC to the local computers only… see the previous post for more details.