Menu
User

DropVPS Team

Writer: Cooper Reagan

How to install TigerVNC server on ubuntu 24.04

How to install TigerVNC server on ubuntu 24.04

Publication Date

05/15/2025

Category

Articles

Reading Time

2 Min

Table of Contents

First, make sure your system is up to date:

sudo apt update && sudo apt upgrade -y

Then, install the desktop environment. Ubuntu Server doesn’t come with a GUI by default. For a lightweight option, install XFCE:

sudo apt install xfce4 xfce4-goodies -y

Next, install the VNC server. We’ll use TigerVNC, which works well with modern Ubuntu versions:

sudo apt install tigervnc-standalone-server tigervnc-common -y

Create a new user (if needed) or use your current user. Then, set a VNC password:

vncpasswd

This sets the password VNC clients will use to connect. You can skip view-only mode by pressing n.

Now, start VNC once to generate the default config files:

vncserver

Then immediately kill the session so we can edit the config:

vncserver -kill :1

Edit the startup file to use XFCE:

nano ~/.vnc/xstartup

Replace everything with:

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

Make the file executable:

chmod +x ~/.vnc/xstartup

Now, start the VNC server again:

vncserver :1

This starts VNC on display :1, usually accessible on port 5901 (since 5900 + display number).

If you’re running a firewall like ufw, open the VNC port:

sudo ufw allow 5901/tcp

For secure remote access, it’s highly recommended to tunnel VNC through SSH. From your client machine, run:

ssh -L 5901:localhost:5901 your-user@your-server-ip

Then connect your VNC viewer to localhost:5901.

To stop the server:

vncserver -kill :1

If you want VNC to start on boot, create a systemd service file:

nano ~/.config/systemd/user/[email protected]

Paste this:

[Unit]
Description=Start TigerVNC server at startup
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=default.target

Enable the service (for display 1):

systemctl --user enable [email protected]

Start it manually with:

systemctl --user start [email protected]

Done. You now have a working VNC server running on Ubuntu 24.04, secured with a password and ready for remote access via SSH tunneling or open port (not recommended unless firewalled properly).

Linux VPS
U
Loading...

Related Posts