Skip to main content

How to Install Ubuntu Desktop and Connect via RDP or VNC

This guide explains how to transform your Linux VPS into an Ubuntu Desktop with a graphical interface, and how to connect remotely via VNC or RDP.

Order a Server

For comfortable Ubuntu Desktop use, HostMyServers offers several options:

Prerequisites

  • SSH access as root or user with sudo privileges
  • Ubuntu Server 20.04, 22.04 or 24.04 installed
  • Minimum 2 GB RAM (4 GB recommended)
  • Minimum 20 GB free disk space
  • Stable internet connection
UsageRAMCPUStorage
Light usage2 GB2 cores20 GB
Standard usage4 GB2-4 cores40 GB
Heavy usage8 GB+4+ cores60 GB+

Part 1: Installing Ubuntu Desktop

System Update

Connect to your VPS via SSH and update the system:

sudo apt update && sudo apt upgrade -y

Installing the Desktop Environment

Install Ubuntu Desktop:

sudo apt install ubuntu-desktop -y
Note

Installation takes about 10 to 15 minutes depending on your server's power and internet connection. Many packages will be downloaded (about 2-3 GB).

Minimal Installation (Alternative)

If you prefer a lighter installation, you can install only the minimal GNOME desktop:

sudo apt install ubuntu-desktop-minimal -y

Or choose a lighter desktop environment like XFCE:

sudo apt install xubuntu-desktop -y

Or LXDE (very light):

sudo apt install lubuntu-desktop -y

Server Restart

Once installation is complete, restart your server:

sudo reboot

VNC offers better fluidity and a more optimized experience for Linux.

Installing TigerVNC Server

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

Configuring VNC Password

Configure the password for VNC connection:

vncpasswd

Answer the questions:

Password: [enter your password]
Verify: [confirm password]
Would you like to enter a view-only password (y/n)? n
Tip

VNC password is limited to 8 characters. Choose a strong password.

Configuring VNC Server

Create a configuration file for startup:

mkdir -p ~/.vnc
nano ~/.vnc/xstartup

Add the following content:

#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 &

For GNOME (standard Ubuntu Desktop), use instead:

#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
export XKL_XMODMAP_DISABLE=1
exec /usr/bin/gnome-session &

Make the file executable:

chmod +x ~/.vnc/xstartup

Starting VNC Server

Launch VNC server with remote access:

vncserver -localhost no

By default, VNC listens on port 5901 (display :1).

Check Status

vncserver -list

Stop VNC Server

vncserver -kill :1

Connecting to VNC Server

  1. Download a VNC client:

    • Windows: RealVNC Viewer or TigerVNC
    • macOS: RealVNC Viewer or built-in VNC client
    • Linux: sudo apt install tigervnc-viewer or Remmina
  2. Connect to address: SERVER_IP:5901

  3. Enter the configured VNC password

Firewall Configuration for VNC

sudo ufw allow 5901/tcp
sudo ufw reload

Automatic VNC Startup

Create a systemd service to start VNC automatically:

sudo nano /etc/systemd/system/vncserver@.service

File content (replace YOUR_USER with your username):

[Unit]
Description=TigerVNC Server for %i
After=syslog.target network.target

[Service]
Type=forking
User=YOUR_USER
Group=YOUR_USER
WorkingDirectory=/home/YOUR_USER
PIDFile=/home/YOUR_USER/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -localhost no :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1.service

Part 3: Connecting via RDP (Alternative)

RDP is convenient if you use Windows as the client is built-in, but less optimized for Linux.

Installing xrdp

sudo apt install xrdp -y

Configuring xrdp

Add the xrdp user to the ssl-cert group:

sudo adduser xrdp ssl-cert

Restarting xrdp Service

sudo systemctl restart xrdp
sudo systemctl enable xrdp

Checking Status

sudo systemctl status xrdp

Firewall Configuration for RDP

sudo ufw allow 3389/tcp
sudo ufw reload

Connecting to RDP Server

From Windows

  1. Open "Remote Desktop Connection" (mstsc.exe)
  2. Enter your server's IP address
  3. Click "Connect"
  4. Enter your Linux username and password

From macOS

  1. Download Microsoft Remote Desktop from the App Store
  2. Add a new PC with your server's IP
  3. Connect with your Linux credentials

From Linux

sudo apt install remmina remmina-plugin-rdp -y

Then launch Remmina and configure a new RDP connection.

Common RDP Troubleshooting

Black Screen After Connection

If you get a black screen, edit the startwm.sh file:

sudo nano /etc/xrdp/startwm.sh

Add these lines before the last lines of the file:

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

Then restart xrdp:

sudo systemctl restart xrdp

Slow Session

To improve performance, reduce the resolution in RDP client settings or change color quality (16 bits instead of 32 bits).

VNC vs RDP Comparison

CriteriaVNCRDP
Performance on Linux⭐⭐⭐⭐⭐⭐⭐⭐
Ease of installation⭐⭐⭐⭐⭐⭐⭐⭐⭐
Built-in Windows client
BandwidthMediumLow
Native securityMediumGood
Recommended forDaily useOccasional access
Recommendation

For regular Ubuntu Desktop use, we recommend VNC which offers better fluidity and better compatibility with the Linux environment.

Securing Connections

To secure your VNC connection with an SSH tunnel:

  1. On your local machine, create the tunnel:
ssh -L 5901:localhost:5901 user@SERVER_IP
  1. Connect via VNC to localhost:5901

This method encrypts the entire VNC connection.

Change VNC Port

For more security, you can use a custom port:

vncserver -localhost no :2

This will create a VNC server on port 5902.

Limit Access by IP

Configure UFW to only allow your IP:

sudo ufw delete allow 5901/tcp
sudo ufw allow from YOUR_IP to any port 5901 proto tcp
sudo ufw reload

Uninstallation

Uninstall VNC

sudo systemctl stop vncserver@1.service
sudo systemctl disable vncserver@1.service
sudo apt remove tigervnc-standalone-server tigervnc-common -y
rm -rf ~/.vnc

Uninstall RDP

sudo systemctl stop xrdp
sudo systemctl disable xrdp
sudo apt remove xrdp -y

Uninstall Ubuntu Desktop

sudo apt remove ubuntu-desktop -y
sudo apt autoremove -y

Troubleshooting

VNC Won't Start

  • Check logs: cat ~/.vnc/*.log
  • Check if port is already in use: ss -tlnp | grep 5901
  • Kill existing sessions: vncserver -kill :1

Cannot Connect

  • Check firewall allows the port: sudo ufw status
  • Check service is running: vncserver -list
  • Test connectivity: nc -zv SERVER_IP 5901

Graphical Interface is Slow

  • Reduce resolution in VNC/RDP client
  • Use a lighter desktop environment (XFCE, LXDE)
  • Increase VPS RAM
  • Check your connection bandwidth

Keyboard Not Working Correctly

For keyboard layout issues, install:

sudo apt install console-data keyboard-configuration -y
sudo dpkg-reconfigure keyboard-configuration

Then restart VNC server or xrdp.