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.
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.
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
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
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.
Running programs built for Microsoft's framework on a Linux system is easier than you think. Mono is…
Computer vision technology powers many modern applications, from image editors to facial scanners. OpenCV (Open Source Computer…
Hosting your own code repositories is a great way to keep your projects private. Gitea is a…
Many modern programs require Java to run. From development tools like Eclipse to search systems…
Setting a static IP address on your server is a smart move. It ensures your…
Xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP). It lets you access…