+5 votes
281 views
in Setting by (242k points)
reopened
How to configure VNC on Raspberry Pi

1 Answer

+3 votes
by (1.6m points)
edited
 
Best answer

VNC server on Raspberry Pi: what is it?
Challenges when setting up VNC server on Raspberry Pi
Tutorial: how do you configure a VNC server on a Raspberry Pi?
Step 1: install or update VNC Connect on Raspberry Pi
Step 2: activate the VNC server
Step 3: check connection settings
Step 4: install VNC Viewer on external devices
Step 5: establish direct connection with the Raspberry Pi (on the local network)
Step 6: establish a cloud connection with the Raspberry Pi VNC server
Step 7: adjust the screen resolution of the Raspberry Pi
Step 8: optimize VNC performance on Raspberry Pi Zero and Pi 1

image

How to configure VNC on Raspberry Pi

Despite its minimal size, the Raspberry Pi manages to please due to the variety of its interfaces (USB, network) and its good performance, so it is no coincidence that the minicomputer is an essential component of many electronic DIY projects and a platform. widely used for server applications of various kinds. Direct operation of the Raspberry Pi with the mouse, keyboard or monitor is not always possible or is often cumbersome, so it is necessary to resort to a separate desktop PC that manages the operating system and the resources of the Raspberry Pi by control remote. For these purposes, Typically, an SSH connection to the minicomputer is established, which provides easy access to the command line interface (CLI). Alternatively, using a VNC server on the Raspberry Pi allows remote access to the graphical user interface..

Index
  1. VNC server on Raspberry Pi: what is it?
  2. Challenges when setting up VNC server on Raspberry Pi
  3. Tutorial: how do you configure a VNC server on a Raspberry Pi?
    1. Step 1: install or update VNC Connect on Raspberry Pi
    2. Step 2: activate the VNC server
    3. Step 3: check connection settings
    4. Step 4: install VNC Viewer on external devices
    5. Step 5: establish direct connection with the Raspberry Pi (on the local network)
    6. Step 6: establish a cloud connection with the Raspberry Pi VNC server
    7. Step 7: adjust the screen resolution of the Raspberry Pi
    8. Step 8: optimize VNC performance on Raspberry Pi Zero and Pi 1

VNC server on Raspberry Pi: what is it?

Under the acronym VNC ( V irtual N etwork C omputing) a client-server that can display and control the software is distributed screen content of the desired system (server) to another system (client). For this, client-side keyboard inputs and mouse clicks and movements are transmitted directly to the remote computer. If you install and activate VNC on a Raspberry Pi you can install, configure and manage the minicomputer from another PC. The basis of VNC is Remote Framebuffer Protocol (RFB), a network protocol suitable for any platform that transmits content as bitmaps and uses TCP port 5900. Since connections are created without state data, the remote sessions created are not lost. even in the event of temporary outages or VNC client changes.

Note

Here we explain how to configure a VNC server on a Raspberry Pi to be able to use it with remote control. Conversely, it is also possible to install a VNC client on the minicomputer to exercise remote control over another PC..

Challenges when setting up VNC server on Raspberry Pi

The VNC software is designed in such a way that it works with fewer resources . The more resources required by the other applications running on the Raspberry Pi, the more relevant this aspect will acquire. In principle, there are no restrictions on the selection of the Raspberry Pi model, so VNC servers can be configured and run on either a 1st generation Raspberry Pi or one with the most current version.

The choice of the appropriate software fell for a long time to the X11VNC or TightVNC solutions . For Raspberry Pi both are appropriate and are still available today. Since the integration of the PIXEL user interface in Raspbian, with VNC Connect the standard operating system has its own virtual network computing application, which has to be activated to make use of the remote management technology. The requirement for this is to use at least Raspbian Jessie , otherwise, you must download and install the client-server software..

Note

VNC Connect and X11VNC allow direct access to the current screen of the Raspberry Pi. In contrast, TightVNC broadcasts virtual versions of the original presentation thus making it possible to simultaneously register multiple users on the VNC server (similar to the traditional terminal server concept).

Tutorial: how do you configure a VNC server on a Raspberry Pi?

In the next tutorial we show you how to configure and use a VNC server on the minicomputer. For our example we will resort to the installation and configuration, very simple, of the VNC Connect client and server components , i.e. the Raspbian standard VNC suite mentioned above.

Step 1: install or update VNC Connect on Raspberry Pi

The first step is to make sure that the current version of VNC Connect is installed on your Raspberry Pi, something that is done by entering the following commands in the terminal:

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

After that, Raspbian will update both the server application and the client (viewer). In theory it is possible to use the minicomputer at any time even to access a VNC server . This, however, is not the subject of this tutorial.

If you are still using an old version of Raspbian or any other operating system, on your Raspberry Pi, you will need to download VNC Connect . To do this, visit the official website of the developer RealVNC and select the installation file for Raspberry Pi in the download center.

Step 2: activate the VNC server

Once you have updated the software, you can start the server, either through the user interface or through the CLI.

In the first case, open the main menu (raspberry symbol) and select the sections? Preferences? Y ? Raspberry Pi configuration ?. Go to the tab? Interfaces ? and states that? VNC? is? Active ?.

To get the VNC server up and running on your Raspberry Pi using the command line interface, you need the raspi-config configuration tool, which starts as follows:

  sudo raspi-config  

Navigate to the button? Interfacing Options ? (interconnect options) and move the mouse to the option? VNC? to activate it in the last instance by pressing? Yes ?. After activating the server, it will start automatically when the Raspberry Pi boots.

Note

Disabling the VNC server works the same way. To do this, choose the opposite options? Deactivated? or not?.

Step 3: check connection settings

If you install and activate VNC Connect on your Raspberry Pi and restart the minicomputer, you will see the icon for the VNC server in the system bar of the user interface. When you click on the icon, a window will appear that will offer you data on the connectivity and security of the remote application. In this way, the left part shows the IP of your Raspberry necessary to establish the connection with the VNC client . Save the address to be able to access it later on the external computer. Alternatively, you can insert the IP in the following terminal command:

  hostname -I  

On the right side there is a signature and keywords to verify identity , which must be displayed by a message when the VNC connection is started later. Thus, it is possible to demonstrate that Raspberry Pi is the target system in question.

advice

If you want to regularly access the Raspberry Pi through VNC, it is recommended that you assign a fixed IP address to the minicomputer.

Step 4: install VNC Viewer on external devices

Once the VNC server is up and running on Raspberry Pi, you can fully dedicate yourself to the computer from which you want to remotely control the minicomputer, on which you must install the client application, that is, VNC Viewer. To do this, RealVNC offers free installation files for different operating systems. Thus, the client can be installed, for example, on Windows, macOS and Linux computers . There are also client applications for Android or iOS, but also a Chrome extension thanks to which the VNC Viewer can be run through the Google browser. In the Real VNC download center you can download the appropriate version and start the installation following the usual pattern.

Step 5: establish direct connection with the Raspberry Pi (on the local network)

The fastest and easiest way to use VNC technology is through the direct connection between the client computer and the Raspberry Pi. The requirement for this is that both devices are connected to the same local network (LAN or WLAN) and the IP of the Raspberry Pi is known . In this case, when starting VNC Viewer, enter the address in the address line intended for it and establish the connection by clicking the Enter key.

image
Before connecting to the VNC server on Raspberry Pi using a Chrome extension, you can provide data on the desired image quality

Subsequently, the client application will present the previously announced message (with signature and keywords) to verify the identity . In the case of the information previously provided by the VNC server, you can continue the process.

Next you will be asked for a username and password , that is, the Raspberry Pi user account, whose username is normally? Pi? and the password? raspberry ?. To prevent access by unauthorized users, it is recommended to modify this data even before starting the VNC server.

Step 6: establish a cloud connection with the Raspberry Pi VNC server

If you do not want or are not able to connect the client system and the Raspberry Pi through a local network, you have the possibility to establish the connection with VNC through the Internet. For these types of cloud connections, which are free for non-commercial purposes and are characterized by end-to-end encryption, you need a RealVNC account, also free and very easy to define. To begin registration, visit the RealVNC website again and enter an email address in the sign up box.

image
It is also interesting to have a RealVNC account when connecting directly with the VNC server of the Raspberry Pi, as this way it is possible, for example, to protect the address book by means of a backup and synchronize it on various devices

The login details for the new RealVNC account (email address and password) are needed twice, that is, in the VNC server application on Raspberry Pi and client-side in VNC Viewer. In the server program, add a shortcut to the account that includes an email and password under the option? Licensing? (authorization) and, to finish, click on ? Sign in? . Register on the client device with the account used in VNC Viewer. After that, Raspberry Pi will automatically appear as an available host, so just double-click on the corresponding symbol to establish the VNC connection.

Step 7: adjust the screen resolution of the Raspberry Pi

Once the remote connection to the Raspberry Pi VNC server is established, there may be two reasons why it is necessary to change the screen resolution of the minicomputer:

  1. The performance is low, as the resolution is very high.
  2. The standard resolution is kept (for example, because the Raspberry is only used in headless mode without being connected to a monitor) and it is too low .

You can find the corresponding adaptation possibilities in the raspi-config tool , which is started by means of the following terminal command:

  sudo raspi-config  

Select the option? Advanced Options ? and then look for the entrance? Resolution ?, where you can select the desired resolution before closing the tool and the CLI.

advice

If you want more control over the HDMI settings of your Raspberry Pi, you can also make changes to the configuration file /boot/config.txt . Using the hdmi_mode input you can define one of more than 50 different HDMI output formats with the appropriate values. In the official manual you can access the complete list of possible values ​​(section? HDMI mode options?).

Step 8: optimize VNC performance on Raspberry Pi Zero and Pi 1

If you have installed the VNC server on Raspberry Pi 1 or Zero, performance will become unstable due to the somewhat weaker processing power of these older models. As long as you are active on a secure local network, you can mitigate this problem by disabling encryption and thereby reducing the CPU load .

Note

Disabling encryption is only possible for direct connections, but not for cloud connections .

Access the VNC server menu on your Raspberry Pi and open the options . Select expert mode and choose? AlwaysOFF ? for the parameter? Encryption ?. Changes are not applied to active sessions, so you must end existing connections and then restart them.


...