VNC stands for Virtual Network Computing. It is, in essence, a remotedisplay system which allows you to view a computing `desktop' environmentnot only on the machine where it is running, but from anywhere on theInternet and from a wide variety of machine architectures.It is implemented in a client/server model. This package provides a clientfor X, with this you can connect to a vncserver somewhere in the networkand display its content in a window. There are vncserver available for otheroperating systems.The difference between the xtightvncviewer and the normal vncviewer is thedata encoding, optimized for low bandwidth connections. If the client do notsupport jpeg or zlib encoding it can use the default one. Later versions ofxvncviewer (> 3.3.3r2) support a new automatic encoding that should be equallygood as the tightvnc encoding. Tags: User Interface: Graphical User Interface, X Window System, Networking: Client, Role: role::program, uitoolkit::athena, Purpose: Login, Data Visualization, X Window System: Application
This is a guide to installing TightVNC on the Raspberry Pi. The latest version of Raspbian now includes the RealVNC which is an alternative remote desktop tool. If you would prefer to use RealVNC then it is easily enabled through the raspi-config tool, this guide will be useful for those wanting to understand about creating other applications to run on start-up through systemd.
The command line is a great way to manage a remote Linux computer if you don't mind typing in commands, but sometimes you need to be able to view a GUI. Short of a very long cable one of the best ways of doing this is using the VNC protocol (Virtual Network Computing).
When most people think of a remote desktop tool then they usually think of the way that RealVNC operates. In this case when you move the mouse, or launch an application it displays the same output on a physically attached screen (normally HDMI) and on a remote client over the network.
TightVNC is useful if you want to run something different to what is on the main screen. For example you could use it so that you can have a status display on the main screen (via HDMI) with a different display used for the configuration which is displayed on a laptop.
Another advantage of TightVNC is that it is FREE open source software. As such it has no restrictions on use and you can view and modify the source code. Real VNC is a commercial version of VNC and needs to be licensed. Real VNC is free to use for personal use on the Raspberry Pi, but does have restrictions if you want to do other things with it which may require a commercial license. This includes running the Raspbian Desktop image on a PC as that does not included the commercial software.
The following are instructions on how to configure this on the Raspberry Pi (Debian based distribution). It should be similar for any other Debian based distribution (eg. Ubuntu) which uses Systemd start-up files. Some other distributions use different software install tools and possibly different init setup tools.
If this is used in combination with the guide to running the Raspberry Pi headless with Debian Linux then it can be used to setup a Raspberry Pi for remote access without ever needing to connect it to a monitor.
There are several software projects that support VNC. I have chosen to use TightVNC because it is free open source software (GPL2), provides compression to allow it to work over a slow network (Internet) and is readily available in the software repositories.
VNC follows the traditional client sever model. The server software runs on the host to be accessed, and client software runs on the local machine that wishes to control the host. The server and client do not have to be the same (eg. the client can be RealVNC when the server is TightVNC), but some features may only work when the same client and server are used.
First refresh the software repository information using
sudo apt update
This is particularly important if you have just installed the operating system as the repository information may be incomplete.
When the server starts it will tell you which virtual desktop has been setup. In this case:
New 'X' desktop is raspberrypi:1
says that it's virtual desktop 1. You would connect to this using :1 at the end of the IP address in the client, this is the one we will setup to start automatically later.
To have Tightvnc startup automatically we need to create a new startup file, which needs to be stored in the /etc/systemd/system/ directory and end with the suffix ".service". I called this tightvncserver.service. This needs to be created as the root user so using sudo
sudo nano /etc/systemd/system/tightvncserver.service
You may need to change the user name on line 8. It is currently set to pi which is the default username on the Raspberry Pi Raspbian image. Set this to whatever username you want to login to TightVNC as. Do not put root as the user.
It's a good idea to test the script at this point rather than waiting until after a reboot. This is done using:
sudo systemctl start tightvncserver.service
Don't worry if you get the following error message, which is because you've already started tightvnc
A VNC server is already running as :1
Note that this is designed for running only one instance of TightVNC on the computer. If you want to be able to start and stop specific instances of TightVNC then you will need to tweak the startup script appropriately.
On a Linux computer you can install the viewer with
sudo apt install xtightvncviewer
or if that is not in the repositories try:
sudo apt-get install ssvnc
This will work with Debian / Ubuntu based distributions only, for other distributions use the normal package manager.
TightVNC allows anyone that knows the password to login as the user that it's running under. It also does this without encryption so anyone can snoop in on the session. Fortunately there is a secure solution, which is to tunnel the connection over an ssh (secure shell) login.
First step is to restrict Tightvnc to the local computer only. This is done by adding the option -localhost when starting the tightvncserver. To do this edit line 7 in the /etc/systemd/system/tightvncserver.service file to read:ExecStart=/usr/bin/tightvncserver -localhost :1Then restart the server.
To connect using tightvnc now use the command
xtightvncviewer 127.0.0.1:1
Note that your previous terminal will now be logged into the Raspberry Pi so you will need to start a new terminal or tab to run the viewer.
For instance with Ubuntu you would use the entry for gnome, for xubuntu you would use xfce and for kubuntu use kde. The Raspberry Pi uses lxde, but this is started automatically on the Raspberry Pi there is no need to add it to the xstartup file.
When connecting to a VNC server with a display larger than the VNC Viewer window, scroll bars appear to allow moving around the larger display. It is possible to scroll down or to the right; however, it is then impossible to scroll back up or to the left. This leaves a significant portion of the display unusable, depending on the size difference between the display and the window.
This bug also exists in the vncviewer program which appears to be installed by default. I was actually going to report this and another bug under package vncviewer, but for some reason the bug reporting system refuses to accept vncviewer as a package name. The other bug with vncviewer, which does not affect xtightvncviewer, is that when connecting to a computer running the built-in VNC server in Mac OS X 10.4 (this can be enabled in the Apple Remote Desktop settings in the Sharing panel of the System Preferences) vncviewer quits with the following output:
I can confirm this. I have the same problem with xtightvncviewer which. This is very annoying since I always have to reconnect with the vncviewer and there seem to be no alternatives except something like UltraVNC through wine. Gnome-rdp has some huge bugs and use the xtightvncviewer too so it doesn't help.
The difference between the tightvncserver and the normal vncserver is thedata encoding, optimized for low bandwidth connections. If the client do notsupport jpeg or zlib encoding it can use the default one. Later versions ofvncserver (> 3.3.3r2) support a new automatic encoding that should be equallygood as the tightvnc encoding.
It is implemented in a client/server model. This package provides a clientfor X, with this you can connect to a vncserver somewhere in the networkand display its content in a window. There are vncserver available for otheroperating systems.
The difference between the xtightvncviewer and the normal vncviewer is thedata encoding, optimized for low bandwidth connections. If the client do notsupport jpeg or zlib encoding it can use the default one. Later versions ofxvncviewer (> 3.3.3r2) support a new automatic encoding that should be equallygood as the tightvnc encoding.
tightvncpasswd: virtual network computing password tool
tightvncpasswd-dbgsym: debug symbols for tightvncpasswd
tightvncserver: virtual network computing server software
tightvncserver-dbgsym: debug symbols for tightvncserver
xtightvncviewer: virtual network computing client software for X
xtightvncviewer-dbgsym: debug symbols for xtightvncviewer
TightVNC is an improved version of VNC, great free remote-desktop tool. The improvements include bandwidth-friendly "Tight" encoding, file transfers in the Windows version, enhanced GUI, many bugfixes, and more.
This tutorial will cover the basics of starting a VNC server, wrapping it in ssh, and connecting to your remote desktop securely. In the following examples we will be connecting to mo.ece.pdx.edu using display 44, which means my port number will be 5944 (VNC port numbers are equal to 5900 plus the display number). Wherever mo.ece.pdx.edu is mentioned, one could also use any Ubuntu or Redhat/Centos Linux machine in MCECS.
If you are attempting to make a VNC connection to a firewalled Linux computer, you will need to make sure that your localLinux computer is connected to one of our VPNs. Popular Linux hosts that are firewalled include:
c80f0f1006