[stordis-toc]
Introduction
noVNC is a VNC client that operates in a web browser. With noVNC, you can use the desktop of an Ubuntu 24.04 machine from any computer. You do not need to install a VNC client.
This guide shows how to install TigerVNC and noVNC, how to start them automatically as system services, and how to connect from a web browser.
Prerequisites
- Ubuntu 24.04 with a desktop environment. On Ubuntu Server, install XFCE (refer to the note below).
- A user account with sudo rights.
- Network access to the machine on TCP port 6080.
What you need
- The IP address of the Ubuntu machine.
- The name of the user that will use the remote desktop. In this guide:
USERNAME. - A VNC password. VNC uses only the first 8 characters of the password.
NOTE
Ubuntu Server has no desktop. Install the light XFCE desktop and set it as the default session for your user:
sudo apt install xfce4 -y echo "xfce4-session" > ~/.xsession
Step 1: Update the system
sudo apt update && sudo apt upgrade -y
Step 2: Install the VNC server and set the password
- Install TigerVNC:
sudo apt install -y tigervnc-standalone-server
- Set the VNC password. Do this as
USERNAME, not as root:
vncpasswd
When the command asks for a view-only password, type n.
Step 3: Test the VNC server
- Start the VNC server on display
:1:
tigervncserver -geometry 1280x720 -localhost yes :1
- If the server starts without errors, stop it:
tigervncserver -kill :1
Display :1 uses TCP port 5901. The -localhost yes option makes the VNC server accept connections only from the same machine. noVNC connects to it locally.
Step 4: Install noVNC and create a certificate
- Install noVNC and websockify:
sudo apt install -y novnc python3-websockify python3-numpy
- Create a self-signed certificate for the encrypted (HTTPS) connection. Do this as
USERNAME:
openssl req -x509 -nodes -newkey rsa:2048 -days 3650 \ -subj "/CN=$(hostname)" \ -keyout ~/novnc.pem -out ~/novnc.pem
The file ~/novnc.pem contains the certificate and the key.
Step 5: Start the VNC server as a service
- Create the service file:
sudo nano /etc/systemd/system/vncserver@.service
- Paste this configuration. Replace
USERNAMEwith your user name (3 places):
[Unit] Description=TigerVNC server on display %i After=network.target [Service] Type=forking User=USERNAME PAMName=login PIDFile=/home/USERNAME/.vnc/%H%i.pid ExecStart=/usr/bin/tigervncserver -geometry 1280x720 -depth 24 -localhost yes %i ExecStop=/usr/bin/tigervncserver -kill %i Restart=on-failure [Install] WantedBy=multi-user.target
- Save the file: press Ctrl+O, Enter, then Ctrl+X.
- Enable and start the service for display
:1:
sudo systemctl daemon-reload sudo systemctl enable --now vncserver@:1
If display :1 is in use, use the next free number, for example :2 (port 5902). Then use the same number in Step 6.
Step 6: Start noVNC as a service
- Create the service file:
sudo nano /etc/systemd/system/novnc.service
- Paste this configuration. Replace
USERNAMEwith your user name (2 places):
[Unit] Description=noVNC web access After=network.target vncserver@:1.service [Service] Type=simple User=USERNAME ExecStart=/usr/bin/websockify --web=/usr/share/novnc/ --cert=/home/USERNAME/novnc.pem 6080 localhost:5901 Restart=on-failure [Install] WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable --now novnc
- Make sure that both services are active (running):
systemctl status vncserver@:1 novnc
Step 7: Allow access through the firewall
sudo ufw allow 6080/tcp sudo ufw reload
Do not open port 5901. The VNC server accepts only local connections, and noVNC is the only entry point.
CAUTION
Before you enable ufw on a remote machine (sudo ufw enable), allow SSH: sudo ufw allow OpenSSH. If you do not, you lose the SSH connection.
Step 8: Connect from a web browser
- In a web browser, open this address:
https://<your-server-ip>:6080/vnc.html
- The browser shows a warning about the certificate, because the certificate is self-signed. Accept the warning to continue.
- Click Connect and type the VNC password.
Pro Tip
Do not make port 6080 available on the internet. For access from outside your network, use a VPN or an SSH tunnel.
Troubleshooting
Show the logs of the two services:
sudo journalctl -u vncserver@:1 -n 50 --no-pager sudo journalctl -u novnc -n 50 --no-pager
The VNC server does not start a desktop session. Make sure that the file ~/.xsession of USERNAME contains xfce4-session (refer to the note in Prerequisites). Then restart the VNC server:
sudo systemctl restart vncserver@:1
- Make sure that the
novncservice is active. - Make sure that the firewall allows TCP port 6080 (
sudo ufw status). - Make sure that the address starts with
https://and ends with/vnc.html.
Procedure completion
Congratulations!
You have successfully set up noVNC on Ubuntu 24.04. Now you can use the Ubuntu desktop from any web browser, and both services start automatically after a reboot.
Happy networking!
Useful links:
How to Set Up RDP on Ubuntu 24.04 for Remote Access?
How to install NTP server in Ubuntu 24.04
For more free resources, visit: https://stordis.com/free-resources/
Comments 0
Comments
Please sign in to leave a comment.