15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started
30.10.2024

How to Connect to Ubuntu from Windows Using RDP (Complete 2024 Guide)

Remote Desktop Protocol (RDP) is one of the most reliable and widely used technologies for accessing and controlling a remote computer over a network. While Windows machines support RDP natively, Ubuntu Linux does not ship with a built-in RDP server — but this limitation is straightforward to overcome. By installing xrdp, an open-source RDP implementation for Linux, you can transform any Ubuntu machine into a fully functional remote desktop server that Windows clients can connect to using the built-in Remote Desktop Connection tool.

Whether you are managing a VPS Hosting environment, administering a remote workstation, or simply need occasional graphical access to a Linux machine from a Windows desktop, this guide walks you through every step: installation, firewall configuration, connecting from Windows, troubleshooting common issues, and hardening security.

What Is xrdp and Why Use It?

xrdp is a free, open-source implementation of Microsoft's Remote Desktop Protocol for Unix-like operating systems. It acts as an RDP server on Linux, accepting incoming connections from any standard RDP client — including the native Remote Desktop Connection (mstsc.exe) built into every version of Windows.

Key advantages of xrdp include:

  • No third-party client required on Windows — use the built-in mstsc tool
  • Full graphical desktop access — interact with a complete Linux GUI remotely
  • Cross-platform compatibility — works with Windows, macOS, and mobile RDP clients
  • Active development and community support
  • Lightweight and easy to configure

This makes xrdp the go-to solution for system administrators who need to bridge Windows and Linux environments without complex software stacks.

Prerequisites

Before you begin, make sure you have the following:

  • An Ubuntu machine (20.04, 22.04, or 24.04 LTS recommended) with sudo privileges
  • The IP address of your Ubuntu machine
  • A Windows PC with Remote Desktop Connection available (included in all Windows versions)
  • A stable network connection between both machines
  • Basic familiarity with the Linux terminal

> Tip: If you are running Ubuntu on a cloud server or a Dedicated Server, ensure your hosting provider's network firewall (not just UFW) also permits traffic on port 3389.

Step 1: Install the xrdp RDP Server on Ubuntu

Ubuntu does not include an RDP server by default, so the first step is to install xrdp from the official Ubuntu repositories.

1.1 — Open the Terminal

Press Ctrl + Alt + T to open a terminal window on your Ubuntu machine, or connect via SSH if you are working on a headless server.

1.2 — Update Package Lists

Always update your package index before installing new software to ensure you get the latest available version:

sudo apt update && sudo apt upgrade -y

1.3 — Install xrdp

sudo apt install xrdp -y

The installation process will automatically pull in all required dependencies.

1.4 — Enable and Start the xrdp Service

Once installed, enable xrdp to start automatically on boot and then start it immediately:

sudo systemctl enable xrdp
sudo systemctl start xrdp

1.5 — Verify xrdp Is Running

Confirm the service is active and running without errors:

sudo systemctl status xrdp

You should see output similar to:

● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled)
     Active: active (running) since ...

If the service is active and enabled, your Ubuntu machine is now ready to accept incoming RDP connections.

Step 2: Configure the UFW Firewall to Allow RDP

By default, Ubuntu's Uncomplicated Firewall (UFW) may block incoming connections on port 3389, which is the standard RDP port. You must explicitly allow this traffic.

2.1 — Allow Port 3389 Through UFW

sudo ufw allow 3389/tcp

2.2 — Enable UFW (If Not Already Active)

If UFW is not yet enabled on your system, activate it with:

sudo ufw enable

> Warning: If you are connected via SSH, make sure to allow SSH traffic first (sudo ufw allow OpenSSH) before enabling UFW to avoid locking yourself out.

2.3 — Verify the Firewall Rules

sudo ufw status

The output should list port 3389/tcp as ALLOW:

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
3389/tcp                   ALLOW       Anywhere

Your Ubuntu machine is now configured to accept RDP connections through the firewall.

Step 3: Find Your Ubuntu Machine's IP Address

Before connecting from Windows, you need to know the IP address of your Ubuntu machine.

Run the following command in the terminal:

hostname -I

Or for more detailed network information:

ip addr show

Note the IPv4 address (e.g., 192.168.1.105 for a local network, or a public IP if connecting over the internet). If you are connecting to a cloud-based VPS, you can find the public IP address in your hosting control panel.

Step 4: Connect to Ubuntu from Windows Using Remote Desktop

With xrdp running and the firewall configured, you can now establish the RDP connection from your Windows machine.

4.1 — Open Remote Desktop Connection

On your Windows computer, press Windows + R to open the Run dialog, type mstsc, and press Enter.

Alternatively, search for "Remote Desktop Connection" in the Start menu.

4.2 — Enter the Ubuntu Machine's IP Address

In the Remote Desktop Connection window, type the IP address of your Ubuntu machine in the Computer field:

192.168.1.105

If you changed the RDP port (covered in Step 6), append the port number:

192.168.1.105:3390

4.3 — Initiate the Connection

Click Connect. You may receive a certificate warning — this is normal for self-signed certificates. Click Yes to proceed.

4.4 — Log In to Ubuntu

The xrdp login screen will appear. Enter your Ubuntu username and password, then click OK.

After a moment, your Ubuntu desktop will load in the Remote Desktop window. You can now interact with it exactly as if you were sitting in front of the machine.

Step 5: Troubleshooting Common RDP Issues

Even with a correct setup, you may encounter a few common issues. Here is how to resolve them.

Issue 1: Black Screen After Login

A black screen immediately after login is the most frequently reported xrdp problem. It typically occurs because the default GNOME desktop environment does not work seamlessly with xrdp sessions.

Solution: Install and configure the Xfce desktop environment, which is lightweight and fully compatible with xrdp.

Install Xfce:

sudo apt install xfce4 xfce4-goodies -y

Configure xrdp to use Xfce:

echo xfce4-session > ~/.xsession

Restart xrdp:

sudo systemctl restart xrdp

Reconnect from Windows — the black screen should be gone and you will see the Xfce desktop.

> Alternative for Ubuntu 22.04+: You can also configure xrdp to use the default GNOME session by editing /etc/xrdp/startwm.sh, but Xfce remains the most reliable choice for remote desktop sessions.

Issue 2: Firewall Blocking the Connection

If the connection times out or is refused, verify your firewall rules:

sudo ufw status verbose

If port 3389 is not listed, re-add the rule:

sudo ufw allow 3389/tcp
sudo ufw reload

Also check whether your cloud provider or router has a separate firewall or security group that may be blocking port 3389 — this is a common oversight when working with hosted servers.

Issue 3: Slow or Laggy Remote Desktop Performance

If the connection feels sluggish, try the following:

  • Reduce display quality: In the Remote Desktop Connection window, click Show Options → Display and lower the color depth and resolution.
  • Reduce screen resolution: Set the remote session to 1280×720 instead of full HD.
  • Check network bandwidth: Run a speed test to rule out network bottlenecks.
  • Use a wired connection instead of Wi-Fi where possible.

Issue 4: Authentication Errors

If login fails despite correct credentials:

  • Ensure the user account exists on the Ubuntu machine and has a password set
  • Check xrdp logs for details: sudo journalctl -u xrdp -n 50
  • Verify that the xrdp SSL certificate is correctly installed: ls /etc/xrdp/cert.pem

Issue 5: xrdp Service Fails to Start

If xrdp does not start, check for configuration errors:

sudo xrdp --nodaemon

This runs xrdp in the foreground and prints errors directly to the terminal, making it easier to diagnose issues.

Step 6: Harden Security for RDP Connections

Exposing RDP on the default port 3389 to the public internet is a significant security risk. Automated bots constantly scan for open RDP ports and attempt brute-force attacks. Follow these best practices to protect your system.

6.1 — Change the Default RDP Port

Changing the port from 3389 to a non-standard port reduces automated attack exposure significantly.

Open the xrdp configuration file:

sudo nano /etc/xrdp/xrdp.ini

Find the line:

port=3389

Change it to a custom port (e.g., 13389 or any unused port above 1024):

port=13389

Save and exit (Ctrl + X, then Y, then Enter), then restart xrdp:

sudo systemctl restart xrdp

Update your firewall to allow the new port and remove the old rule:

sudo ufw allow 13389/tcp
sudo ufw delete allow 3389/tcp

6.2 — Restrict Access by IP Address

If you always connect from a known IP address, restrict RDP access to that IP only:

sudo ufw allow from 203.0.113.50 to any port 3389 proto tcp

Replace 203.0.113.50 with your actual IP address. This dramatically reduces your attack surface.

6.3 — Use a VPN for Encrypted Tunneling

The most secure approach is to not expose RDP to the public internet at all. Instead, connect to a VPN first, then use RDP over the encrypted VPN tunnel. This keeps port 3389 completely hidden from the internet while still allowing authorized users to connect.

Popular VPN solutions compatible with Ubuntu include WireGuard and OpenVPN.

6.4 — Use Strong Passwords and Enable Two-Factor Authentication

  • Set a strong, unique password for every user account that can log in via RDP
  • Consider implementing two-factor authentication (2FA) using tools like Google Authenticator with PAM (Pluggable Authentication Modules)
  • Disable unused user accounts to minimize the attack surface

6.5 — Keep xrdp and Ubuntu Updated

Regularly update your system to patch known vulnerabilities:

sudo apt update && sudo apt upgrade -y

6.6 — Monitor Login Attempts

Use Fail2Ban to automatically block IP addresses that repeatedly fail authentication:

sudo apt install fail2ban -y

Fail2Ban can be configured to monitor xrdp logs and ban offending IPs after a defined number of failed attempts.

Alternative: SSH Tunneling for Secure RDP

For maximum security without a full VPN setup, you can tunnel your RDP connection through SSH. This encrypts the RDP traffic and avoids exposing port 3389 publicly.

On Windows, use PuTTY or the built-in OpenSSH client to create a local port forward:

ssh -L 3389:localhost:3389 username@your-ubuntu-ip

Then connect Remote Desktop Connection to localhost:3389 — the traffic will be securely tunneled through SSH.

Choosing the Right Hosting Environment for Remote Desktop

The performance and reliability of your RDP session depend heavily on the underlying infrastructure. Here are some recommendations based on use case:

Use CaseRecommended Solution
Personal remote access / testingShared Web Hosting with SSH, or entry-level VPS
Developer workstation / small teamVPS Hosting with 2–4 vCPUs and 4–8 GB RAM
High-performance remote desktopDedicated Servers for full resource isolation
AI/ML workloads with GUIGPU Hosting for GPU-accelerated remote sessions

For teams that prefer a managed control panel interface, VPS with cPanel provides an intuitive web-based management layer alongside your remote desktop access.

Quick Reference: Complete Setup Checklist

Use this checklist to confirm every step has been completed correctly:

  • [ ] sudo apt update && sudo apt upgrade -y
  • [ ] sudo apt install xrdp -y
  • [ ] sudo systemctl enable xrdp && sudo systemctl start xrdp
  • [ ] sudo ufw allow 3389/tcp (or custom port)
  • [ ] Noted Ubuntu machine's IP address (hostname -I)
  • [ ] Installed Xfce if black screen occurs (sudo apt install xfce4 -y)
  • [ ] Configured ~/.xsession for Xfce (echo xfce4-session > ~/.xsession)
  • [ ] Connected from Windows using mstsc
  • [ ] Changed default RDP port for security
  • [ ] Enabled Fail2Ban or IP restriction

Conclusion

Setting up an RDP connection from Windows to Ubuntu using xrdp is a practical, efficient, and cost-effective solution for remote Linux desktop access. By installing xrdp, selecting a compatible desktop environment like Xfce, configuring the firewall, and applying security hardening measures, you can establish a stable and secure remote desktop session in under 15 minutes.

Whether you are managing a local Ubuntu workstation, a cloud-based VPS, or a Dedicated Server, xrdp eliminates the need for third-party remote access tools and leverages the familiar Windows Remote Desktop client that most administrators already know. Combined with best practices like VPN tunneling, custom ports, IP restrictions, and Fail2Ban, your remote desktop environment can be both highly accessible and robustly secured.

15%

Save 15% on All Hosting Services

Test your skills and get Discount on any hosting plan

Use code:

Skills
Get Started