How To Install and Setup VNC Server On Linux


Virtual Network Computing or simply popular name VNC is a protocol mostly used by Linux servers to create remote desktop connection. VNC is also used for different operating systems like MacOS, Windows, Unix, BSD etc. There are different VNC client and server sides applications like TightVNC, TigerVNC, RealVNC etc. We will prefer VNC application provided by Ubuntu distribution which is TightVNC.

Desktop Environment

Desktop Environment is group of applications used to provide GUI desktop experience to the user. There are different Desktop Environments like GNOME, KDE, Xfce, LXDE etc. In this tutorial we assume you have all ready install one of those desktop environment. VNC server will provide installed Desktop Environments. If there is no desktop environment or it is not configured correctly generally a black screen will appear.

Install VNC

As we stated before we will install VNC server into Ubuntu. We  assume that we have an existing Desktop as stated previously. We will install tightvncserver package from Ubuntu yaketty but alternative VNC servers or alternative distributions can be installed with similar steps like below. As we will install app we need root privileges which can be provided with sudo or with root user.

Install VNC

Install VNC

VNC Server Configurations

The most error prone and important part of the setup of VNC Server is configuration part. We will run vncserver command and follow the steps.

We will provide a password for the current user vncserver session. There is also an verification step to be sure password in entered correctly.

LEARN MORE  How To Install,Start, Stop, Restart OpenSSH In Ubuntu, Debian, Kali, Mint?

We have configured VNC Server and created session number 1 which is stated as ubu2:1 with the host name. Here ubu2 is the hostname and 1 is the session number which also specifies a port.

VNC server ports starts from tcp 5900 by default and session number is added to find related port number. For example session 1 is tcp port 5900+1=5901 .

Connect To VNC Server

To connect VNC server we need some VNC client in the client computer. There is no problem if the client and server applications are different. In this situation we use Tightvnc client too. First open client.

And put the host and session information like above ubu2:1 . There is also alternative expression format by provided port number directly like ubu2:5901 . And click connect. There is also Options part which is used to configure connection parameters like window size, compression algorithm, compression ratio, cursor behavior etc.

We should enter password in to the provided box like below.

And we will get our desktop if there is no problem

Connect With Ssh Tunnel

By default VNC is not an encrypted protocol. This can create security problems. One of the steps to take in order to make more secure is tunelling via encrypted channels like ssh tunnels. Ssh encrypted and secure protocol. Ssh provides tunneling which can be used for all network streams and connections. Following command will create a secure channel between client and server.

  • -L 5901: will bind our localhost port number 5901 to the remote ssh server local port 5901
  • -N used to do not execute remote command
  • -f used to send ssh to the background
  • ismail@ubu2 used to provide user ismail and server ubu2

Kill VNC Server

Killing will just stop provided session and do not kill whole VNC server or other sessions do not provided. There is a practical command which will use session number like below.

LEARN MORE  UEFI or Unified Extensible Firmware Interface

Kill VNC Server

Kill VNC Server

You may also like...

2 Responses

  1. devops online training says:

    Nice Article. How it help to developer in terms of balance the day to day life.

  2. devops online training says:

    Wow. That is so elegant and logical and clearly explained. Brilliantly goes through what could be a complex process and makes it obvious.

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)