raspberry-pi-real-vnc

Remote Desktop Connection VNC to Raspberry Pi with RealVNC

  • 6 min

VNC is a remote desktop system that lets you view and control another computer’s screen over the network.

In many cases we will not have our Raspberry Pi connected to a monitor and keyboard, but instead using it for tasks such as a media center, web server, home automation, or robotics.

In these cases, we need a way to control our device remotely. SSH is perfect for working from the terminal, but when we need to see the full desktop, a VNC connection can be very convenient.

Unlike SSH, which only opens a command console, with VNC we can have a full remote desktop. That is, on the client’s screen we will see the Raspberry Pi’s screen, move the mouse, and use it almost as if we were physically connected.

Despite its simplicity and convenience, a remote desktop also has its disadvantages. The main one is that it needs to transmit a large amount of data, especially due to the need to send the video signal. Although modern systems use video compression, the performance is slower than with a physical connection or an SSH connection.

Other disadvantages of remote desktop, combined with having to send the video connection, are, for example, that we might have some resolution issues, or not be able to view certain elements that are launched directly on the server’s GPU (such as some video players, webcams, or streaming videos).

Finally, VNC is less secure than SSH, so the communication is more susceptible to being intercepted by an attacker. Although it is possible to tunnel the VNC connection over SSH and some clients incorporate encryption in the communication, keep in mind that accessing via SSH is more secure.

What is VNC?

Virtual Network Computing is a remote communication system based on the RFB (Remote FrameBuffer) protocol. VNC transmits the video signal and mouse and keyboard events between several computers.

VNC and RFP were originally developed by the Olivetti & Oracle Research Lab in Cambridge. They were created as a simple way to perform remote desktop between devices with different operating systems. In 2002, the project was discontinued and part of the team continued it independently, forming the company RealVNC.

The VNC system follows a client-server architecture. By default, it works over TCP on port 5900 and onwards, with one port per video session. Therefore, port 5900 is assigned to session :0 (usually the physical display), 5901 to session :1, and so on.

Currently there are more remote desktop systems, similar to or even evolved from VNC. There are also different VNC-compatible applications such as RealVNC, TightVNC, UltraVNC, TigerVNC, or WayVNC, among others, each with its own strengths and quirks.

The workflow shown below is the classic one using RealVNC, which for years was the most common option on Raspberry Pi OS.

In Raspberry Pi OS Bookworm and later, with Wayland, the remote desktop landscape has changed. Raspberry Pi Connect and WayVNC are very convenient current options, while RealVNC fits better with older installations or X11 sessions.

Configure VNC on Raspberry Pi

The computer we are going to connect to, in this case our Raspberry Pi, must have a VNC server installed. In many Raspberry Pi OS distributions the server is available, but not necessarily enabled by default.

To activate the VNC server on Raspberry Pi, we need to go into the Raspberry Pi configuration and activate the corresponding option as we saw in the post How to configure Raspberry Pi with GUI or command line.

On the other hand, it is convenient to have a static IP configured, so it doesn’t change every time we restart the Raspberry Pi. We saw how to configure a static IP in the post Configure static IP on Raspberry Pi.

The configured VNC will, in principle, only work on the local network. If you want to connect from outside (through the Internet), you will need to configure port forwarding on your router and ensure the connection is secure.

If we are running an operating system that does not have the VNC server installed, we can install it by running these commands.

sudo apt-get update sudo apt-get install realvnc-vnc-server realvnc-vnc-viewer

Configure the Client

To connect to the Raspberry Pi, we must install the viewer program on the client, which can be a computer, a tablet, a mobile phone (and of course another Raspberry Pi). We have clients available for Windows, Linux, Mac, and Android.

As we said, in this post we will focus on RealVNC. Download and install the RealVNC viewer suitable for your operating system from https://www.realvnc.com/.

raspberry-pi-real-vnc

Alternatively, we can also use the Chrome extension, which we can install from the Chrome Web Store. Later, we can access it by entering this link in the browser: chrome://apps/

raspberry-pi-real-vnc-extension

Regardless of whether we use one program or another (each with its own interface), the process to connect is similar. First, we configure a remote computer by indicating the IP of the system we want to connect to. This configuration is saved so it’s convenient to connect to our machines.

raspberry-pi-real-vnc-config

When starting the connection, we will be asked for the username and password of our Raspberry Pi.

raspberry-pi-real-vnc-login

It is a serious risk to expose a Raspberry Pi to the Internet with VNC enabled and weak credentials. For remote access from outside the local network, it is better to use encrypted and well-authenticated solutions, such as Raspberry Pi Connect, VPN, or SSH tunnels.

It is possible that the first time we connect with a VNC, a message will appear saying that the device’s signature is not known. It’s okay, it’s a protection measure to prevent spoofing. If it’s the first time we are connecting, we simply accept to continue.

raspberry-pi-real-vnc-autorizacion

If the connection has been successful, we will see the Raspberry Pi’s video on our computer screen and will be able to interact with it almost as if we had the monitor and keyboard connected directly.

raspberry-pi-real-vnc-conexion

Congratulations! That is how easily you have correctly configured remote desktop with VNC. For a local network it is a convenient solution; for Internet access, it is worth thinking about it a bit more and not opening ports recklessly.