However, this isn’t always practical. You’re probably using your monitor for your main PC. Or, it might be your main TV. Whatever the situation, there comes a time when you find that it would just be a whole lot easier to remotely connect to your Raspberry Pi.

What Is VNC?

Virtual Network Computing uses the remote frame buffer protocol to give you control of another computer, transmitting keyboard and mouse input to the remote computer and sending output back across the network to your display.

This means that you can launch programs remotely on your Raspberry Pi, adjust settings in the Raspbian GUI and generally use the desktop environment much as you would with the Pi plugged into your monitor.

Using TightVNC to Remote Connect to Your Raspberry Pi

Setting up remote access to your Raspberry Pi with TightVNC is simple. Begin by running a package update:

sudo apt-get update

…before proceeding to install the TightVNC server for Linux:

sudo apt-get install tightvncserver

Note that you can either do this with your monitor plugged in, or remotely using the command line via SSH.

With the server application installed run it:

tightvncserver

Finish by starting the VNC server:

vncserver :0 -geometry 1920x1080 -depth 24

This creates a session on display 0 – keep a note of this as you will need it when you connect.

To connect to this server session, you’ll first need to install TightVNC on your desktop computer. Linux users should simply install the TightVNC viewer:

sudo apt-get install xtightvncviewer

Meanwhile, Windows and Mac OS X users can download the client from www.tightvnc.com/download.php. Make sure you launch TightVNC Viewer on your computer, as the download package will also install TightVNC Server on your PC.

With the TightVNC Viewer running, enter the IP address or device name of your Raspberry Pi, followed by a colon and the number of the sessions. For instance, to connect to session 0, created above, enter MyRaspberryPi:0, replacing “MyRaspberryPi” with your own device name or IP address.

Run VNC at Boot

As things stand, this will only work if you run tightvncserver each time you reboot the Raspberry Pi, which means first establishing an SSH connection – not ideal! However, you can overcome this by creating a startup script.

Begin by creating a new file in nano:

sudo nano vnc.sh

and entering the following script:

#!/bin/sh
vncserver :0 -geometry 1920x1080 -depth 24 -dpi 96

With this entered, press CTRL+X to exit the text editor, selecting Y to save. Next, set the permissions:

sudo chmod +x vnc.sh

You can run this by entering

./vnc.sh

Another script is now required, but first you’ll need to login as root, and navigate to the correct directory:

sudo su
cd /etc/init.d/

Create another file in nano, this time called vncboot:

sudo nano vncboot

Enter the following (copy and paste should work, but check that it hasn’t pasted multipe times).

You can test this is working by rebooting your Raspberry Pi, and attempting a VNC connection from your PC.

Once up and running, you should be able to interact with most desktop apps and settings. Some users find TightVNC slow, however. Fortunately there is an alternative – a sort of VNC over SSH solution.

VNC over SSH with Xming

If you have followed our guide to SSH, or have previously used the service, you will know that such connections are operated via an SSH client. On Windows, this is probably PuTTY, which you should have installed already.

Get started by downloading Xming from Sourceforge and installing, confirming that the PuTTY link is selected in the installation wizard.

Once Xming is installed, find the desktop shortcut, right-click and select Properties. In the Target field, ensure that the file address is appended as follows:

“C:\Program Files (x86)\Xming\Xming.exe” :0 -clipboard -multiwindow

If the text in bold is not present, add it in and click Apply.

When done, launch Xming. Windows Firewall will attempt to block the program, so wait for this box to appear and click Allow.

We’re nearly there. In PuTTY, expand the menu tree on the left and go to Connection > SSH > X11. Here, check Enable X11 forwarding. Return to the Session view, then enter the IP address or device name for your Raspberry Pi, perhaps saving the session if you plan on using those settings again.

Remote Connect Using Microsoft RDP

Another option for remote connections between desktop PCs and Raspberry Pi is Microsoft RDP. This is built into Windows Vista and later, so no additional software is required on your PC.

On your Raspberry Pi, open a Terminal window and install xrdp.

sudo apt-get install xrdp

Once installed, this will run whenever an authenticated connection is made from your PC, as xrdp runs as a service. Launch Remote Desktop Connection in Windows (W8.x and later can simply search for “rdp” to find this) and in the Computer field, input the IP address of your Pi. When you click connect, Windows should ask you to confirm connection, as the identity of the target computer will not be clear. As you know that it is your Raspberry Pi, and on your network, it is safe to proceed.

Nothing really. These instructions are very similar to what I have read elsewhere. Once the Xming program is running and the X11 forwarding is set in putty, the terminal window will open, ask for login info, and go to the command line, just like it always does. No x server opens in windows. checked the log, saw this:

Christian Cawley is MakeUseOf's security and Linux editor, with extensive experience in IT desktop and software support. Christian is a regular contributor to print publications such as Linux User & Developer, as well as a number of specials: Raspberry Pi for Beginners, Expert Android, The iPad Book Vol 6, WordPress…