How to Set Up noVNC on Ubuntu 24.04 for Remote Access via Web Browser?

[stordis-toc]

Introduction 

noVNC is a web-based VNC client that allows you to access your Ubuntu 24.04 system remotely via a browser. This guide will show you how to install and configure noVNC for seamless remote access.

Prerequisites

  • Ubuntu 24.04 installed
  • Sudo privileges
  • A stable internet connection

Note

Remember to use desktop linux, or if you are using server linux you need to have some light interface installed e.g. XFCE. To do it just use commmand:

sudo apt install xfce4 -y

and set it as default desktop environment:

echo "xfce4-session" > ~/.xsession

Step-By-Step Instruction

STEP 1: Update Your System

Before installing any software, update your package list:

sudo apt update && sudo apt upgrade -y

STEP 2: Install a VNC Server

noVNC requires a VNC server to function. Install TigerVNC:

sudo apt install -y tigervnc-standalone-server

Set a VNC password:

vncpasswd

Start the VNC server to check if it starts correctly:

tigervncserver -xstartup /usr/bin/xfce4-session -SecurityTypes VncAuth,TLSVnc -geometry 1280x720 -localhost no :1

Stop it if it started correctly:

tigervncserver -kill :1

Warning

Starting the process manually as shown above may lead to permission-related issues. For proper operation and to ensure appropriate privileges, it is recommended to run it as a system service. Please follow the instructions through to the end for detailed guidance on how to set it up.

STEP 3: Install and Configure noVNC

Install noVNC and websockify:

sudo apt -y install novnc python3-websockify python3-numpy

Start noVNC with:

websockify -D --web=/usr/share/novnc/ --cert=/home/ubuntu/novnc.pem 6080 localhost:5901

STEP 4: Allow Access Through the Firewall

Open the necessary ports:

sudo ufw allow 6080/tcp
sudo ufw reload

STEP 5: Connect to Ubuntu via Web Browser

  1. Open a web browser and navigate to:
http://<your-server-ip>:6080/vnc.html
  1. Click Connect and enter your VNC password.

STEP 6: Enable noVNC to Start Automatically

  • Open the crontab editor:
sudo crontab -u username -e
  • At the end of the file, add the following line:
@reboot websockify -D --web=/usr/share/novnc/ --cert=/home/ubuntu/novnc.pem 6080 localhost:5901

If using nano, press CTRL + X, then Y, and Enter to save.

  • Open a new systemd service file:
sudo nano /etc/systemd/system/vncserver@:1.service
  • Paste the following configuration, replacing USERNAME with your actual username:
[Unit]
Description=Start TigerVNC server at startup
After=network.target

[Service]
Type=forking
User=USERNAME
PAMName=login
PIDFile=/home/USERNAME/.vnc/%H:1.pid
ExecStart=/usr/bin/tigervncserver -geometry 1280x720 -depth 24 :1
ExecStop=/usr/bin/tigervncserver -kill :1
Restart=always

[Install]
WantedBy=multi-user.target

If display :1 is already in use, change it to another available number.

  • After saving the file, run the following commands to enable the service at startup:
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1
sudo systemctl start vncserver@:1
  • To verify that the service is running, use:
systemctl status vncserver@:1

 

If you encounter issues, check the service logs:

sudo journalctl -u novnc --no-pager | less

To restart service use:

sudo systemctl restart vncserver@:1

 

Congratulations!

You have successfully set up noVNC on Ubuntu 24.04, allowing remote access via a web browser. 

Now, you can securely access your Ubuntu desktop from anywhere using just a web browser!

 

If you want to explore more topics, be sure to check out our other guides, including:

How to Set Up RDP on Ubuntu 24.04 for Remote Access?

 

For more free resources, visit: https://stordis.com/free-resources/

Comments 0

Articles in this section