Install VNC on Debian 10 - Step by step guide ?

VNC (Virtual Network Computing) server is free and open-source software that is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas the VNC viewer is used on the remote computer to connect to the server.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux system VNC connection queries.

In this context, we shall look into how to install VNC on Debian 10.


Step to Install and configure VNC on Debian 10 Buster

1. Perform System Update 

Before we install any software, it's important to make sure your system is up to date by running the following apt-get commands in the terminal:

$ sudo apt update
$ sudo apt upgrade


2. Install VNC Server on your system

Now we use the TigerVNC server. This package provides a standalone VNC server that is used to connect to the clients. Use the install command to download the package:

$ sudo apt install tigervnc-standalone-server tigervnc-common

Once successfully installed the next step is to run the vncserver the command which will create the initial configuration and set up the password:

$ vncserver


3. Configure VNC Server

You should first stop the VNC server which is running on port 5091 with the following command:

$ vncserver -kill :1

The next step is to create the systemd unit file named vncserver@.service:

$ sudo nano /etc/systemd/system/vncserver@.service

Paste the following content:

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
 
[Service]
Type=forking
User=root
Group=root
WorkingDirectory=/home/root
 
PIDFile=/root/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
 
[Install]
WantedBy=multi-user.target

Then, enable the unit file with the following command:

$ sudo systemctl daemon-reload
$ sudo systemctl enable vncserver@1.service
$ sudo systemctl start vncserver@1.service


How to Connect to VNC server ?

To access the remote desktop on the VNC server from the windows system, you must have a VNC viewer installed on your system. There is various VNC viewer available to use. Download any one and install on your system, for example:

If you are using putty, then you need to set the ssh tunneling. You can enable ssh tunneling in Linux by running the below command:

$ ssh -L 5901:127.0.0.1:5901 -C -N -l username your_server_ip


How to Run VNC as a System Service ?

Now we will configure the VNC server as a systemd service so that we can start, stop and restart the service like any other. This will also allow us to set the service to start automatically on boot.

First, create a systemd file called /etc/systemd/system/vncserver@.service:

$ sudo vim /etc/systemd/system/vncserver@.service

In the file, add the below lines and replace your user, group, working directory, and the user in the PID file to match your username:

[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=debian
Group=debian
WorkingDirectory=/home/debian
PIDFile=/home/debian/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target

Save and close the file then reload the daemon:

$ sudo systemctl daemon-reload 

Then enable the service to start automatically on boot:

$ sudo systemctl enable vncserver@1.service 

Stop the running instance:

$ vncserver -kill :1

Start the VNC service with the command:

$ sudo systemctl start vncserver@1

Check the status of the service:

$ sudo systemctl status vncserver@1


[Need assistance in configuring VNC on your Linux system ? We can help you. ]

This article covers the process of installing VNC on Debian 10 Buster system. In fact, VNC stands for Virtual Network Computer. This is a graphical desktop sharing system that uses the Remote Frame Buffer protocol(RFB). There are many software services that provide VNC, among them are TigerVNC, Vino, VNC4server, TightVNC e.t.c

Related Posts