How to Install and Configure VNC Server on Debian 9 Stretch

vnc server debian9

VNC (Virtual Network Computing) is a technology for remote desktop sharing. VNC enables the visual desktop display of one computer to be remotely viewed and controlled over a network connection. It is similar to MSTSC on windows. It uses the Remote Frame Buffer protocol (RFB) to remotely control another computer.

Keystrokes and mouse clicks are transmitted from one computer to another, allowing technical support staff to manage a desktop, server, or another networked device without being in the same physical location. VNC is useful on home computer networks, allowing someone to access their desktops from another part of the house or while traveling.

Out of most popular available desktop environments, XFCE is the quite lightweight. It uses a surprisingly low amount of memory (especially when you look it from a Windows perspective), while at the same time looking decent and working just as well as any other Linux flavor. We will use XFCE in this tutorial. However, you can also use other popular desktop environments like KDE, GNOME, and Unity. Ok, Let's go with the installation.

Step 1 : Installation of VNC and XFCE

Update the packages list available in the repositories by executing first command 'apt-get update'. The second command will do the actual installation of tightvncserver and XFCE4 with useful addons.

$ apt-get update
$ apt-get install xfce4 xfce4-goodies gnome-icon-theme tightvncserver

Installation may take a while depeding on the dependencies installed on the machine.

Step 2 : Create a VNC User

To keep things secure and robust, we will create separate user vnc connection. You can also you existing user.
Create a user named vnc by using this command. You can keep username as per your choice. It will ask for the new password and user details. Enter password and you can skip the other details by pressing ENTER key.

$ adduser vnc

Install sudo by executing this command. We will need to add vnc user to sudo group.

$ apt-get install sudo

Now, Add vnc user to sudo group, it will give permission to vnc user to act like a root user and execute root command.

$ gpasswd -a vnc sudo
Adding user vnc to group sudo

switch to a vnc user for further operations.

su - vnc

Step 3 : Start VNC server

you can start the server by this command.

$ vncserver

You will require a password to access your desktops.

Would you like to enter a view-only password (y/n)? y
xauth:  file /home/vnc/.Xauthority does not exist

New 'X' desktop is 578e1bb09561:1

Creating default startup script /home/vnc/.vnc/xstartup
Starting applications specified in /home/vnc/.vnc/xstartup
Log file is /home/vnc/.vnc/578e1bb09561:1.log

As we have are starting server first time after installation it will ask us to set a password that client use to connect. It will also ask to set view-only password which will allow the user to see the screen but not interact with it. If you enter the password longer than the password policy which is 6-8 character long, it will automatically trim off the password, please keep this in mind.

By default, VNC is configured to listen on TCP port 5901 for first display and 5902 for second display and so on.

Step 4 : Connect from VNC client

Let's test our setup by connecting to vnc server, For that we need local vnc client, it depends upon the local operating system. I am using windows and I am going to use Realvnc as a client.

RealVNC is available for almost all operating system platform like Windows, macOS, Linux (Debian and RPM based), Solaris, etc. You can use other clients also.

Open Realvnc and enter {vnc-server_host name_or_ip}:5901 in vnc server address. My vnc server IP is So, I am using

Add vnc server details in vnc viewer
VNC server home screen after successful connection

You straightway start by clicking "Use default config". Great, You have successfully configured vnc server with client.

Stop VNC server

Use below command to stop vnc server on port Dispay 1 (or on port 5901)

$ vncserver -kill :1

:1 is the display number that is going to be killed.

We have successfully installed and configured VNC server. Now you have realized that it is very useful in different contexts. We have also installed XFCE desktop environment, You can try your favorite desktop environment also. If you find any issue while configuring VNC server or client, Let me know.

7 Comments... add one

    • I just tried it and it does work. I'm using a toshiba running Linux Mint (MX version based upon debian stretch not Ubuntu). I'm connecting to the toshiba machine using 'straight' Mint (which is based upon Ubuntu).

      The connection works, though cinnamon (on both machines) crashes in the vnc session. The fallback works fine however.

      I also realized that this is not really what I wanted. What I'm really looking for is desktop sharing via vnc (and ssh of course).


Leave a Comment