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 Mono on Ubuntu 18.04: C# Compiler and Runtime Guide

Running programs built for Microsoft's framework on a Linux system is easier than you think. Mono is…

1 hour ago

Install OpenCV on Ubuntu 18.04: Step-by-Step Setup Guide

Computer vision technology powers many modern applications, from image editors to facial scanners. OpenCV (Open Source Computer…

1 hour ago

Install Gitea on Ubuntu 18.04: Self-Hosted Git Service Guide

Hosting your own code repositories is a great way to keep your projects private. Gitea is a…

2 hours ago

Install Java on Ubuntu 18.04: OpenJDK 11 and OpenJDK 8

Many modern programs require Java to run. From development tools like Eclipse to search systems…

2 hours ago

Configure a Static IP Address on Ubuntu 18.04: Netplan Guide

Setting a static IP address on your server is a smart move. It ensures your…

1 day ago

Install Xrdp on Ubuntu 18.04: Remote Desktop Setup Guide

Xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP). It lets you access…

1 day ago