Technology Encyclopedia Home >Set Up a Remote Desktop on a Cloud Server — Access a Full Linux GUI from Any Computer

Set Up a Remote Desktop on a Cloud Server — Access a Full Linux GUI from Any Computer

Sometimes you need a real graphical desktop environment on your cloud server: to run GUI applications, test software visually, or just prefer working in a desktop interface rather than a terminal. This guide covers two approaches: RDP (using xRDP, the standard remote desktop protocol supported natively by Windows and macOS) and VNC (more universal, works from any OS with a VNC viewer).

I use a remote desktop on a cloud server primarily for running GUI-based tools that don't have headless alternatives — browser automation testing, certain design tools, and the occasional GUI database client.

I run this on Tencent Cloud Lighthouse. The 2 GB RAM / 2 vCPU plan handles XFCE desktop; 4 GB for full GNOME or KDE. Lighthouse complements a remote desktop setup in a practical way: OrcaTerm gives you browser-based terminal access as a fallback if the RDP/VNC connection has issues, so you're never completely locked out. The static public IP also means your RDP client always connects to the same address, and the console-level firewall lets you restrict desktop access to specific IP ranges for security.


Table of Contents

  1. RDP vs VNC — Which to Use
  2. What You Need
  3. Part 1: Install a Desktop Environment
  4. Part 2: Set Up xRDP (Remote Desktop Protocol)
  5. Part 3: Set Up VNC (Alternative)
  6. Part 4: Connect from Your Devices
  7. Part 5: Secure Remote Desktop Access
  8. The Thing That Tripped Me Up
  9. Troubleshooting
  10. Summary

  • Key Takeaways
  • Use the appropriate Lighthouse application image to skip manual installation steps where available
  • Lighthouse snapshots provide one-click full-server backup before major changes
  • OrcaTerm browser terminal lets you manage the server from any device
  • CBS cloud disk expansion handles growing storage needs without server migration
  • Console-level firewall + UFW = two independent protection layers

RDP vs VNC — Which to Use {#rdp-vs-vnc}

Feature RDP (xRDP) VNC
Protocol Microsoft RDP VNC/RFB
Client on Windows Built-in (Remote Desktop) Needs VNC viewer
Client on macOS Microsoft Remote Desktop (free) Many options (RealVNC, TigerVNC)
Client on Linux Remmina, freerdp Many options
Client on iOS/Android Microsoft RD (free) VNC Viewer
Performance Better (adaptive compression) Moderate
Security SSL/TLS by default Needs tunneling for security
Audio support Yes Limited

Recommendation: Use xRDP if you connect from Windows or macOS — it's smoother and clients are pre-installed. Use VNC if you need maximum compatibility or connect from unusual platforms.


What You Need {#prerequisites}

Requirement Details
Server Ubuntu 22.04, 2 GB+ RAM
Desktop environment XFCE (lightweight) or GNOME/KDE
Open port 3389/tcp (RDP) or 5901/tcp (VNC) — via SSH tunnel only

Part 1: Install a Desktop Environment {#part-1}

Option A — XFCE (Recommended: Lightweight, ~500 MB RAM)

sudo apt update
sudo apt install -y xfce4 xfce4-goodies

Option B — GNOME (Full desktop, ~1.5 GB RAM)

sudo apt install -y ubuntu-desktop-minimal

Option C — LXDE (Minimal, ~300 MB RAM)

sudo apt install -y lxde

For most cloud server use cases, XFCE is the right choice — it's responsive, stable, and doesn't consume excessive resources.


Part 2: Set Up xRDP (Remote Desktop Protocol) {#part-2}

2.1 — Install xRDP

sudo apt install -y xrdp
sudo systemctl enable xrdp
sudo systemctl start xrdp

2.2 — Configure xRDP to Use XFCE

Create a session file for the ubuntu user (or your user):

echo "xfce4-session" > ~/.xsession
chmod +x ~/.xsession

Configure xRDP's startup script:

sudo nano /etc/xrdp/startwm.sh

Add at the top (before the test commands):

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

This prevents a common black screen issue.

Restart xRDP:

sudo systemctl restart xrdp

2.3 — Open the RDP Port in Firewall

sudo ufw allow from YOUR_LOCAL_IP to any port 3389
sudo ufw reload

Security note: Don't open port 3389 to all IPs (0.0.0.0/0). Either restrict to your IP or use an SSH tunnel (covered in Part 5).

Also open the port in your Lighthouse console firewall with the same IP restriction.


Part 3: Set Up VNC (Alternative) {#part-3}

3.1 — Install TigerVNC

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

3.2 — Set VNC Password

vncpasswd
# Enter and confirm a VNC password
# When asked "Would you like to enter a view-only password?" → No

3.3 — Create VNC Startup Script

mkdir -p ~/.vnc
nano ~/.vnc/xstartup
#!/bin/bash
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4
chmod +x ~/.vnc/xstartup

3.4 — Start VNC Server

vncserver :1 -geometry 1920x1080 -depth 24

This starts a VNC server on display :1 (port 5901).

Check it's running:

vncserver -list

3.5 — Auto-Start VNC as a Service

Create /etc/systemd/system/vncserver@.service:

sudo nano /etc/systemd/system/vncserver@.service
[Unit]
Description=VNC Server for display %i
After=syslog.target network.target

[Service]
Type=simple
User=ubuntu
PAMName=login
PIDFile=/home/ubuntu/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver %i -geometry 1920x1080 -auth /home/ubuntu/.Xauthority
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable vncserver@:1
sudo systemctl start vncserver@:1

Part 4: Connect from Your Devices {#part-4}

RDP from Windows

  1. Press Win + R, type mstsc
  2. Computer: YOUR_SERVER_IP:3389
  3. Username: ubuntu
  4. Password: your server user's password
  5. Click Connect

RDP from macOS

  1. Install Microsoft Remote Desktop from App Store (free)
  2. Click + → Add PC
  3. PC name: YOUR_SERVER_IP:3389
  4. User account: ubuntu and your password
  5. Connect

RDP from iOS/Android

Install Microsoft Remote Desktop (iOS) or RD Client (Android), same setup.

VNC from Any Platform

Download a VNC viewer:

  • Windows/macOS/Linux: RealVNC Viewer (free)
  • iOS: VNC Viewer (RealVNC)
  • Android: VNC Viewer (RealVNC)

Connect to: YOUR_SERVER_IP:5901

Enter your VNC password when prompted.


Part 5: Secure Remote Desktop Access {#part-5}

Never expose RDP (port 3389) or VNC (port 5901) directly to the internet. These ports are constantly attacked by brute-force bots.

The secure approach: access via SSH tunnel.

SSH Tunnel for RDP

On your local machine (Mac/Linux):

ssh -L 3389:localhost:3389 ubuntu@YOUR_SERVER_IP -N &

Then connect your RDP client to localhost:3389 instead of the server IP.

On Windows (using PowerShell):

ssh -L 3389:localhost:3389 ubuntu@YOUR_SERVER_IP -N

Then mstsc /v:localhost:3389.

SSH Tunnel for VNC

ssh -L 5901:localhost:5901 ubuntu@YOUR_SERVER_IP -N &

Connect VNC viewer to localhost:5901.

Close Direct Ports in Firewall

After setting up SSH tunneling, remove direct port access:

sudo ufw delete allow 3389/tcp
sudo ufw delete allow 5901/tcp

Now remote desktop access only works through an SSH tunnel, which is encrypted and authenticated with your SSH key.


The Thing That Tripped Me Up {#gotcha}

After connecting via xRDP, I got a grey screen with only a mouse cursor — no desktop loaded. The cursor moved but nothing appeared.

This is a common xRDP issue caused by session conflicts. It happens when:

  1. You have an active local or previous session on the server
  2. The .xsession file isn't read correctly
  3. DBUS environment variables conflict

Multi-step fix:

First, kill any existing sessions:

# On the server via SSH
sudo pkill xfce4-session
sudo pkill Xorg

Second, ensure the ~/.xsession fix is applied:

echo "xfce4-session" | tee ~/.xsession
chmod +x ~/.xsession

Third, add the environment variable unset to /etc/xrdp/startwm.sh:

sudo nano /etc/xrdp/startwm.sh

Add at the very beginning:

#!/bin/sh
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR

Fourth, restart xRDP:

sudo systemctl restart xrdp

Reconnect — you should now get a full XFCE desktop.


Troubleshooting {#troubleshooting}

Issue Likely Cause Fix
Grey/black screen in RDP Session conflict Kill existing sessions; check startwm.sh
Connection refused Port not open or wrong port Check UFW and Lighthouse firewall; verify service is running
Login fails Wrong credentials Use your Ubuntu user's password, not a new password
VNC display resolution wrong Resolution not set Set -geometry 1920x1080 in vncserver command
Desktop loads but very slow High latency or low bandwidth Use RDP (better compression); try lower resolution
Can't install apps via GUI Missing display variable Set DISPLAY=:1 for VNC or DISPLAY=:10.0 for RDP sessions
Font rendering looks wrong Missing fonts sudo apt install fonts-dejavu fonts-liberation

Summary {#verdict}

What you set up:

  • Full Linux GUI desktop (XFCE) on your cloud server
  • xRDP for standard Remote Desktop Protocol connections
  • VNC as an alternative for broader compatibility
  • SSH tunneling for secure access without exposing desktop ports
  • Connections from Windows (built-in RDP), macOS (Microsoft RD), iOS, Android

A remote desktop on a cloud server is particularly useful for running graphical applications, browser automation, or visual testing without needing a powerful local machine.

Frequently Asked Questions {#faq}

Is self-hosted remote desktop suitable for production use?
Yes — remote desktop is used in production environments ranging from individual developers to small teams. Pair it with regular Lighthouse snapshots and stay current with updates.

How do I migrate from a cloud-hosted remote desktop to self-hosted?
Export your data from the cloud service, import it to the self-hosted instance, update DNS or internal service configurations, and verify everything works before switching fully.

How much disk space does remote desktop need?
Initial installation is minimal. Disk usage grows with usage — artifacts, repositories, and caches accumulate over time. Monitor with df -h and use CBS cloud disk expansion when needed.

How do I set up backups for remote desktop?
Use Lighthouse snapshots for full-server recovery. Additionally, export remote desktop's application data directly (usually a backup command or data directory export) for granular restore capability.

Can I run remote desktop alongside other services on the same server?
Yes, with sufficient RAM. Check the resource requirements and monitor actual usage. Containerized deployments (Docker) provide good isolation between services.

👉 Get started with Tencent Cloud Lighthouse
👉 View current pricing and launch promotions
👉 Explore all active deals and offers