How To

Install VNC on Ubuntu 18.04: Step-by-Step TigerVNC Setup

A remote desktop interface makes it easy to manage a remote computer. VNC (Virtual Network Computing) is a protocol that shares the graphical desktop of a server over the network. It allows you to use your mouse and keyboard to control applications on a remote system.

This guide will show you how to install VNC on Ubuntu 18.04 using TigerVNC. We will set up a lightweight desktop environment and show you how to connect securely.

Install a Desktop Environment and TigerVNC

Most servers do not come with a graphical desktop interface. We will install Xfce, which is a fast, lightweight desktop environment that works well over slow connections.

Open your terminal and update your package lists:

bashsudo apt update

Install Xfce and the TigerVNC packages:

bashsudo apt install xfce4 xfce4-goodies tigervnc-standalone-server tigervnc-common

Once the installation is complete, run the password setup command:

bashvncpasswd

Enter a secure password when prompted. You can choose to create a view-only password. This is useful if you want to share your screen with others without letting them control the mouse.

Configure the VNC Startup Settings

We need to tell the VNC server which desktop environment to load when it starts up.

Create the configuration directory and file:

bashmkdir -p ~/.vncnano ~/.vnc/xstartup

Paste the following script into the file:

bash#!/bin/bashxrdb $HOME/.Xresourcesstartxfce4 &

Save the file and exit the editor. Make the startup script executable:

bashchmod +x ~/.vnc/xstartup

Set Up a System Service for VNC

Creating a service file allows you to run VNC automatically when the system boots.

Create the service file:

bashsudo nano /etc/systemd/system/vncserver@.service

Add the following configuration. Replace your_username with your actual system username:

ini[Unit]Description=Start TigerVNC server at startupAfter=syslog.target network.target[Service]Type=forkingUser=your_usernameExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%iExecStop=/usr/bin/vncserver -kill :%i[Install]WantedBy=multi-user.target

Enable and start the service on display port 1:

bashsudo systemctl daemon-reloadsudo systemctl enable vncserver@1sudo systemctl start vncserver@1

Connect to Your Remote Desktop Securely

VNC does not encrypt network traffic. To protect your password and data, you should tunnel the connection through SSH.

On your local machine, run this command to create an SSH tunnel:

bashssh -L 59000:localhost:5901 -N -f your_user@your_server_ip

Open your local VNC viewer software and connect to localhost:59000. You will be prompted for the VNC password you set earlier.

You now have a secure VNC desktop session running on your Ubuntu 18.04 server. Using an SSH tunnel ensures your credentials and data remain private over public networks. If you have any feedback or questions, leave a comment below.

Cyber Defence

Recent Posts

Install Samba on Ubuntu 18.04: Configure Shares and User Access

Samba is a free, open-source implementation of the SMB/CIFS network protocol that lets Linux servers share…

15 hours ago

Set Up an OpenVPN Server on Ubuntu 18.04 with EasyRSA and UFW

Running your own VPN gives you full control over your traffic, privacy, and connection security. It encrypts…

15 hours ago

Install IntelliJ IDEA on Ubuntu 18.04 via Snap: Setup Guide

IntelliJ IDEA is a full-featured IDE for JVM and Android development made by JetBrains. It includes…

15 hours ago

Install Steam on Ubuntu 18.04: Multiverse Setup and First Run

Steam is a cross-platform digital distribution platform by Valve Corporation that gives you access to thousands…

15 hours ago

Install Redmine on Ubuntu 18.04 with MySQL, Passenger, and Nginx

Redmine is one of the most popular open-source project management and issue tracking platforms. It is…

15 hours ago

Install VirtualBox on Ubuntu 18.04 from the Oracle Repository

VirtualBox is a free, open-source, cross-platform virtualization application maintained by Oracle. It lets you run multiple…

2 days ago