However, this is not always practical. You are probably using your main computer monitor. Or it could be your main TV. Regardless of the situation, there comes a point when you find that it would be much easier to remotely connect to your Raspberry Pi.
This is where VNC comes in.
What is VNC?
Network Virtual Computing uses the Remote Frame Buffer Protocol to give you control over another computer by passing keyboard and mouse input to the remote computer and sending output over the network to your display.
This means you can run programs remotely on your Raspberry Pi, tweak settings in the Raspbian GUI, and generally use the desktop environment just as you would if the Pi was connected to your monitor.
Using TightVNC to Connect to Raspberry Pi Remotely
Setting up remote access to your Raspberry Pi with TightVNC is very easy. Start by running a package update:
sudo apt-get update
… Before proceeding with the installation of the TightVNC server for Linux:
sudo apt-get install tightvncserver
Note that you can do this with a connected monitor or remotely using the command line via SSH.
Once the server application is running, run it:
Finish by starting the VNC server:
vncserver :0 -geometry 1920x1080 -depth 24
This creates a session on display 0 — remember this as you will need it when you connect.
To connect to this server session, you first need to install TightVNC on your desktop computer. Linux users should simply install the TightVNC viewer:
sudo apt-get install xtightvncviewer
In the meantime, Windows and Mac OS X users can download the client from www.tightvnc.com/download.php . Make sure you are running TightVNC Viewer on your computer as the download package will also install TightVNC Server on your computer.
When TightVNC Viewer is running, enter the IP address or device name of the Raspberry Pi followed by a colon and the number of sessions. For example, to connect to session 0 created above, type My Raspberry Pi: 0 replacing «MyRaspberryPi» with your own device name or IP address.
Start VNC on boot
As things stand, this will only work if you run thinvncserver when every reboot of the Raspberry Pi, which means establishing an SSH connection first — not ideal! However, you can overcome this by creating a startup script.
Start by creating a new file in nano:
sudo nano vnc.sh
and enter the following script:
#!/bin/sh vncserver :0 -geometry 1920x1080 -depth 24 -dpi 96
Once entered, press CTRL + X to exit the text editor and select Y to save. Next, set permissions: