How To Install and Setup VNC Server On Linux? – POFTUT

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.

$ apt install tightvncserver/yakkety -y
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.

$ vncserver

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

VNC Server Configurations
VNC Server Configurations

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

LEARN MORE  How To Install and Use Telnet Client In Linux and Windows

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.

$ vncviewer
Connect To VNC Server
Connect To VNC Server

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.

Connect To VNC Server
Connect To VNC Server

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

VNC Password
VNC Password

And we will get our desktop if there is no problem

VNC Desktop
VNC Desktop

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 tunneling 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.

$ ssh -L 5901:127.0.0.1:5901 -N -f  ismail@ubu2
  • -L 5901:127.0.0.1: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.

$ vncserver -kill :1
Kill VNC Server
Kill VNC Server

3 thoughts on “How To Install and Setup VNC Server On Linux?”

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

    Reply

Leave a Comment