Configure VNC on Raspbian to remotely access the Pixel desktop of the Raspberry Pi

The Raspbian distribution supports the VNC remote desktop. It is very simple to set up and activate and does not require any technical skills to do it. The Raspberry Pi is an ideal platform for learning programming and electronics. You can recycle old computer equipment (screen, keyboard, mouse, SD card, 5V smartphone charger). The alternative is to access the Raspberry graphical desktop (called Pixel) remotely via a special connection called VNC which stands for Virtual Network Computing. To work, a VNC server must be installed on the Raspberry Pi, which will be responsible for managing the access rights, sending the screen image (like a video stream) and managing the user’s interactions. (keyboard mouse). If another computer (or why not a tablet or a smartphone), we will use a client (or Viewer).

Find the IP address of Raspberry Pi

You will need to know the address assigned by the router to the Raspberry Pi. To do this, open the Terminal and run the ifconfig command. Here, the RPI is at 192.168.1.24 on the local network. Follow this tutorial if you need to assign a fixed IP address to your Raspberry Pi.

raspberry pi ifconfig domoticz adresse ip serveur

Configure VNC on Raspbian

VNC allows access to Raspbian’s graphical desktop from another computer and tablet. Open the Terminal and run raspi-config with the sudo raspi-config  command. Select Option 5 (Interfacing Option)

activate vnc raspbian raspberry pi

Then P3 VNC

activate vnc raspbian raspberry pi

The first time you activate VNC on the Raspbian distribution, you have to install all the necessary packages.

Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances       
Lecture des informations d'état... Fait
Les paquets supplémentaires suivants seront installés : 
  bc cups cups-browsed cups-client cups-common cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-ppdc cups-server-common
  ghostscript gsfonts libcupscgi1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libfontembed1 libgs9 libgs9-common libgutenprint2 libijs-0.35
  libjbig2dec0 libpoppler46 libqpdf13 poppler-data poppler-utils printer-driver-gutenprint qpdf
Paquets suggérés :
  cups-bsd foomatic-db-compressed-ppds foomatic-db printer-driver-hpcups hplip cups-pdf xpp ghostscript-x gutenprint-locales fonts-japanese-mincho
  fonts-ipafont-mincho fonts-japanese-gothic fonts-ipafont-gothic fonts-arphic-ukai fonts-arphic-uming fonts-nanum gutenprint-doc
Les NOUVEAUX paquets suivants seront installés :
  bc cups cups-browsed cups-client cups-common cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-ppdc cups-server-common
  ghostscript gsfonts libcupscgi1 libcupsfilters1 libcupsimage2 libcupsmime1 libcupsppdc1 libfontembed1 libgs9 libgs9-common libgutenprint2 libijs-0.35
  libjbig2dec0 libpoppler46 libqpdf13 poppler-data poppler-utils printer-driver-gutenprint qpdf realvnc-vnc-server
0 mis à jour, 31 nouvellement installés, 0 à enlever et 0 non mis à jour.
Il est nécessaire de prendre 20,9 Mo dans les archives.
Après cette opération, 86,9 Mo d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer ? [O/n] O

Accept the installation (O key) of the new packages. Raspbian takes care of everything, including installing the VNC server’s autostart script when the system boots.

Install a VNC viewer

There are many VNC clients for all platforms (macOS, Windows, Linux …) and for smartphones (iOS, Android …). RealVNC (website) is available on all platforms (including mobile). It is free for personal use. If you prefer to stay in 100% Open Source and free projects, pledge of privacy, you can turn to UltraVNC (official project page).

Go to the RealVNC site to retrieve the VNC viewer that matches your system.

telecharger realvnc vnc

Install and launch VNC Viewer on your computer.

In the address bar, enter the IP address of the Raspberry Pi (ifconfig command to find it) and confirm by pressing the Enter key on the keyboard. It is not necessary to specify port (5900) unless it has been manually changed.

adresse ip raspberry pi realvnc vnc viewer client

In the window that appears, enter your username and password.

connexion raspbian raspberrypi realvnc vnc

RealVNC informs you that the connection is not secure (it does not matter if you connect to the Raspberry Pi from a local network). Accept

realvnc alerte securite raspbian non securise

Here you are on your Raspberry Pi: D. There is nothing more to configure. VNC starts automatically when the system starts! Here, my Raspberry Pi 3 test that also runs a Jeedom home automation server.

TightVNC

TightVNC (official project page) is a lightweight VNC server that runs on all Linux distributions as well as on Windows. This is an alternative to RealVNC used by the Raspberry Foundation. It requires more settings and configuration than RealVNC. It’s up to you to choose the solution that suits you best. Turnkey or Power User.

To install and configure TightVNC, follow this tutorial written for Armbian on an Orange Pi also applies to Raspbian Stretch.

Secure (encrypt) VNC access

If you connect to your Raspberry Pi from your local network, the lack of SSL encryption is not required. Everything can be intercepted on the network. The video stream, the actions with the mouse, the keys of the keyboard … If security is your obsession or if you must regularly access your Raspberry Pi from the internet (from your work or your smartphone), it is wise and strongly advised to encrypt your exchanges with this one.

There are several methods:

  • Create an SSH tunnel into which the VNC stream will be injected. Follow this tutorial to set it up
  • Use VNC Connect from RealVNC. Follow this tutorial by François Mocq (in french)
Note. To access the Raspberry Pi from the internet, you will have to redirect the port to the IP address of the Raspberry Pi. VNC uses port 5900.

Add VNC access to a new user

If you need to add a new user to the system, it is necessary to configure a new output to the VNC server. To do this, simply open an SSH connection or Terminal and execute the vncserver command. Here for example, I added a user pi to Jeedom’s image.

VNC(R) Server 6.1.1 (r28093) ARMv6 (May 19 2017 12:59:35)
Copyright (C) 2002-2017 RealVNC Ltd.
RealVNC et VNC sont des marques de commerce de RealVNC Ltd, déposées et/ou en
cours de dépôt dans l'Union européenne, aux États-Unis et dans d'autres pays.
Protégé par le brevet nº 2481870 au Royaume-Uni ; nº 8760366 aux États-Unis ;
nº 2652951 dans l'UE.
Voir https://www.realvnc.com pour plus d'informations sur VNC.
Pour les avis de propriété intellectuelle d'entreprises tierces, voir :
https://www.realvnc.com/docs/6.1/foss.html

Génération de la clé privée... terminé
Si un environnement de bureau ne se charge pas pour ce bureau virtuel, voir :
 https://www.realvnc.com/doclink/kb-345
Exécution d'applications dans /etc/vnc/xstartup

Alias VNC Server : "Saint complex ground. Crash deluxe Julius."
       signature : 06-4a-cd-d9-96-17-d9-de

Fichier journal : /home/pi/.vnc/jeedom:2.log
Nouveau bureau : jeedom:2 (192.168.1.24:2)

By launching the vnc server, it automatically configures a new output. It is accessed by adding: 2 after the IP address

To go further, here are more tutorials on Raspbian that might interest you

Subscribe to the weekly newsletter

No spam and no other use will be made of your email. You can unsubscribe anytime.

DIY Projects