Your Raspberry Pi is an amazing little computer, but it can be a bit inconvenient. Under normal use, you need to plug in a keyboard and mouse and hook it up to a HDMI monitor (although other displays can be used) in order to view the command line or desktop.

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.

We've previously explained how to connect using SSH, which delivers remote command line access. But what if you need access to the Raspberry Pi desktop from your PC or laptop?

This is where VNC comes in.

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.

Up until recently, my own preferred VNC solution for Windows to Pi connections was via TightVNC, a VNC solution that is lightweight, if a little sluggish.

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.

muo-raspivnc

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).

        #! /bin/sh
# /etc/init.d/vncboot

### BEGIN INIT INFO
# Provides: vncboot
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.
### END INIT INFO

USER=pi
HOME=/home/pi

export USER HOME

case "$1" in
start)
echo "Starting VNC Server"
#Insert your favoured settings for a VNC session
su - pi -c "/usr/bin/vncserver :0 -geometry 1280x800 -depth 16 -pixelformat rgb565"
;;

stop)
echo "Stopping VNC Server"
/usr/bin/vncserver -kill :0
;;

*)
echo "Usage: /etc/init.d/vncboot {start|stop}"
exit 1
;;
esac

exit 0

Next, make the file executable:

        chmod 755 vncboot
    

Finish with

        update-rc.d /etc/init.d/vncboot defaults
    

...or if this doesn't work...

        update-rc.d vncboot defaults
    

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.

Windows users can take advantage of Xming, a VNC-style solution that offers faster performance and additional reliability. Like standard SSH, however, this depends on SSH being enabled on your Raspberry Pi, which you can do using raspi-config (it's enabled by default).

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

muo-rpi-vnc-xming-properties

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.

muo-rpi-vnc-xming-forwarding

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.

Click Connect – seconds later, you'll be enjoying a virtual desktop experience over SSH!

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.

muo-rpi-vnc-windows-rdp

When prompted, input the username and password of your Pi account. If, for example, you hadn't changed the defaults, this would be username: pi and password: raspberry.

In a moment, you should be remotely connected to your Raspberry Pi!

We're looked at three remote desktop solutions for the Raspberry Pi. Which is your favorite? Do you use different remote desktop tools? Tell us about it in the comments.