In this tutorial, we will show you how to install a VNC server on Ubuntu 22.04 LTS. For those of you who didn’t know, Virtual Network Computing, or VNC, is a connection system that allows you to use your keyboard and mouse to interact with a graphical desktop environment on a remote server. VNC is working on GUI (Graphical User Interface) environments, it transmits movements of your mouse and keyboard input over the network using the Remote Frame Buffer (RFB) protocol.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the VNC server on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install VNC Server on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2
Step 2. Installing Desktop Environment.
By default, Desktop environments are usually not included with a server edition. You’ll need to have a GUI installed on your remote server in order to control it. Run the following command below to install it:
sudo apt install xfce4 xfce4-goodies
During installation, You will see a prompt to select a display manager for your newly installed XFCE Desktop Environment:
Step 3. Installing the VNC server on Ubuntu 22.04.
By default, the VNC server is not available on Ubuntu 22.04 base repository. Now run the following command below to install TigerVNC to your Ubuntu system:
sudo apt install tigervnc-standalone-server
After that, run the
vncserver the command to set a VNC access password, create the initial configuration files, and start a VNC server instance:
Once upon setting up the password, you will get a prompt to set a View-Only password. That means anybody who accesses the VNC server with a view-only password will not be able to VNC desktop with either Mouse or Keyboard:
Would you like to enter a view-only password (y/n)? N /usr/bin/xauth: file /home/idroot/.Xauthority does not exist New 'idroot:1 (idroot)' desktop at :1 on machine idroot Starting applications specified in /etc/X11/Xvnc-session Log file is /home/idroot/.vnc/idroot:1.log Use xtigervncviewer -SecurityTypes VncAuth -passwd /home/idroot/.vnc/passwd :1 to connect to the VNC server.
Note that if you ever want to change your password or add a view-only password, you can do so with the
Step 4. Configure the VNC server.
First, stop the VNC server instance that is running on port 5901 with the following command:
vncserver -kill :1
Next, we need to edit the
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak nano ~/.vnc/xstartup
Add the following lines below:
#!/bin/sh # Start up the standard system desktop unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS /usr/bin/startxfce4 [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources x-window-manager &
Save and close the file, then make this file executable:
chmod +x ~/.vnc/xstartup
Next, restart the VNC server:
vncserver -localhost no :1
Step 5. Connecting to your VNC Remote Desktop.
You’re probably familiar with your terminal if you are on Linux or macOS. Create an SSH connection on your local computer that securely forwards to the localhost connection for VNC:
ssh -L 59000:localhost:5901 -C -N -l server_user_name server_ip_address
To access the remote desktop on the VNC server from the windows system, you must have a VNC viewer installed on your system. There is various VNC viewer available to use. Download anyone and install it on your system, for example:
Congratulations! You have successfully installed VNC. Thanks for using this tutorial for installing the VNC server on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official VNC website.