Setting up VNC


VNC (Virtual Network Computing) is a graphical desktop-sharing system that uses the Remote Frame Buffer protocol (RFB) to remotely control another computer.

VNC is kind of like SSH, but it comes with a Graphical user interface. VNC operates on the port number 5901.

Let’s assume that you have just installed your first VPS, with Linux. Probably Debian, Red Hat or Ubuntu. After the installation you get the SSH credentials to log in to your VPS (Linux).

Usually when the service provider installs the operating system, the installation is headless, so there is no desktop environment or graphical user interface.

Side note: Headless commonly means, that there is no graphical user interface (GUI).

Now we assume that your installation is Debian based, because it’s rather strange to see Arch Linux based server. The servers are usually either Debian or Red Hat (Fedora) based.

When talking about servers, they usually don’t have GUI, because it’s a waste of space and also a security vulnerability.

We do an exception here and we plan to install XFCE, because it’s lightweight and doesn’t consume that much memory.

So log in to your server with SSH and enter the following command(s)

sudo apt install xfce4 xfce4-goodies

Next we install TightVNC Server

sudo apt install tightvncserver

Run the application or software with the following command. This will start the installation.

vncserver

Note that the password length can be only 8 characters. You can answer ‘no’, to that view-only password.

After the installation is finished, we need to stop or close the server.

vncserver -kill :1

Create a copy of the configuration file.

sudo cp ~/.vnc/xstartup ~/.vnc/xstartup.backup

Edit the configuration file, so it looks something like this.

#!/bin/sh

xrdb "$HOME/.Xresources"
xsetroot -solid grey
startxfce4 &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make Gnome work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession

Save the file and make the file executable.

sudo chmod +x ~/.vnc/xstartup

Open a port to your firewall

sudo ufw allow 5901

Alternative solution

If you are not interested in VNC, there is alternative solution. Alternatively you could try remmina. We haven’t used that before, so we can’t say much about it.

Source(s):