How to Enable RDP Using xrdp on Ubuntu

By
Sara Zivanov
Published:
February 26, 2025

Remote Desktop Protocol (RDP) is developed by Microsoft and allows users to remotely access and interact with a server GUI.

In Linux, RDP is used with the help of X Remote Desktop Protocol (xrdp), an open-source protocol that allows a remote desktop connection from a Windows machine (or any system that supports RDP) to a Linux machine.

In this tutorial, you will learn how to enable RDP using xrdp on Ubuntu.

How To Enable RDP Using xrdp on Ubuntu.

Prerequisites

  • A Linux system.
  • Sudo or root privileges.
  • A local Windows system with an RDP client installed.

Install Desktop Environment

To use xrdp, install a desktop environment on a Linux server. A desktop environment provides the graphical interface xrdp relies on to allow remote GUI access. 

This tutorial uses the Xfce desktop environment, a lightweight and user-friendly option. To install Xfce, run the following command:

sudo apt install xfce4 xfce4-goodies -y
sudo apt install xfce4 xfce4-goodies -y terminal output

The prompt asks you to choose which display manager to run by default:

Choosing display manager to run by default

The two most common options are:

  • gdm3 (GNOME Display Manager). The default display manager for GNOME-based desktop environments. It is feature-rich but heavier in terms of resource usage.
  • lightdm. A lighter, more flexible display manager commonly used with Xfce and other lightweight desktop environments.

For Xdce, a lightweight desktop environment, lightdm is the recommended choice. Choose it on the next screen:

Choose lightdm

Install xrdp

Xrdp is an open-source remote desktop protocol server that establishes connections to the Linux server from either a remote Windows machine or another Linux system by utilizing the RDP protocol.

RDP uses the client-server model:

  • An RDP client installed on a local machine.
  • An RDP server installed on the remote server.

The Ubuntu machine is the server because it is the system being accessed remotely via RDP. You install xrdp on this machine to allow it to accept remote desktop connections.

Follow the steps below to install xrdp:

1. Execute the following command:

sudo apt install xrdp -y
sudo apt install xrdp -y terminal output

2. Confirm the installation with:

sudo systemctl status xrdp
sudo systemctl status xrdp terminal output

This output shows the status as active (running). If the status is not active, execute the following command to start the service:

sudo systemctl start xrdp

If successful, the command prints no output.

Configure xrdp

The xrdp.ini file, the default configuration file for establishing RDP connections, is located at /etc/xrdp/xrdp.ini. In most cases, xrdp functions without requiring any alterations to the xrdp.ini file for primary remote desktop access.

However, users can customize the configuration to suit any specific requirements. To do so, open the xrdp.ini file using the preferred text editor, for example, Vim:

sudo vim /etc/xrdp/xrdp.ini
sudo vim /etc/xrdp/xrdp.ini terminal output

The config file is split into several sections:

  • Globals. Defines global configuration.
  • Logging. Specifies parameters for the logging system.
  • Channels. Determines channel parameters.
  • Session types. Enumerates the supported session types in separate sections.

Some potential changes to make include:

  • Adjust the username and password settings.
  • Set the screen resolution.
  • Configure color depth.
  • Define a session timeout value to disconnect inactive sessions automatically.
  • Specify the maximum number of concurrent connections allowed by xrdp.

After making changes, save and exit the file. To apply the modifications, restart the xrdp service:

sudo systemctl restart xrdp

Configure System Firewall

To let RDP connections through your server's firewall, configure it to allow connections on port 3389 from either the local network or specific IP addresses.

For public access, ensure proper security measures, such as using a VPN or firewall rules that restrict access.

To configure the firewall on your Ubuntu server, follow these steps:

1. Determine the public IP address by running curl with ifconfig:

curl ifconfig.me
curl ifconfig.me terminal output

If successful, the command prints your IP address.

2. Allow access to port 3389 on the Ubuntu server with the following syntax:

sudo ufw allow from [your_public_ip]/32 to any port 3389

Replace [your_public_ip] with the output obtained from the previous command:

sudo ufw allow from 188.2.254.130/32 to any port 3389
sudo ufw allow from 188.2.254.130/32 to any port 3389 terminal output

3. Enable UFW and apply the rules:

sudo ufw enable
sudo ufw enable terminal output

4. Verify the UFW (Uncomplicated Firewall) configuration is correct and port 3389 is now set to accept connections:

sudo ufw status
sudo ufw status terminal output

Test RDP Connection

To ensure the Ubuntu server is properly configured and accessible via RDP, try connecting to it from a Windows machine using the Remote Desktop Connection application.

If everything is set up correctly, you can establish a remote desktop session and access the Ubuntu desktop environment.

Access your Windows machine and take the following steps:

1. Launch the Remote Desktop Connection app. Find it in the Start menu or search Remote Desktop Connection.

Remote Desktop Connection app in Windows

2. Type the remote server's public IP into the Computer field.

Type in remote server IP

Note: If the Computer and User name fields are not visible, reveal them by clicking the Show Options arrow.

3. Type in the username in the User name box. 

Type in User name

Note: If you don't know your User name, run whoami on your Ubuntu terminal.

4. Click the Connect button. 

Establishing connection

5. The first time you connect to the Ubuntu server, you'll see a Security Warning that the identity of the remote computer cannot be verified. This is standard because you're connecting to a new system. Click Yes.

6. Once the connection is established, the system shows the login screen.

Login screen

Once logged in, access the Ubuntu Desktop environment:

Ubuntu via remote access from Windows

Conclusion

This tutorial explained how to enable RDP using xrdp and connect via a remote desktop connection from a Windows to an Ubuntu machine.

Next, learn how to connect to a remote server via SSH from Windows, Linux, or Mac.

Was this article helpful?
YesNo