How To Enable RDP Using xrdp on Ubuntu

September 7, 2023

Introduction

Remote Desktop Protocol (RDP) is a protocol developed by Microsoft that allows users to remotely access and interact with a server GUI. In Linux, RDP is used with the help of xrdp, an open-source protocol that helps users connect to the Linux server remotely.

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

How To Enable RDP Using xrdp on Ubuntu.

Prerequisites

  • A Linux system (this tutorial uses Ubuntu 22.04).
  • Sudo or root privileges.
  • A local Windows system with an RDP client installed (this tutorial uses the Remote Desktop Connection application).

Install Desktop Environment

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

Note: Run sudo apt update before proceeding.

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.

Note: The most suitable desktop environment depends on your preferences and needs. Check out other popular options in How to Install a GUI on Ubuntu.

Install xrdp

Xrdp is an acronym for X Remote Desktop Protocol. It is an open-source remote desktop protocol (RDP) server, enabling users to establish 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.

Follow the steps below to install xrdp on a server:

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 (Remote Desktop Protocol) 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 make adjustments, open the xrdp.ini file using the preferred text editor. This tutorial uses 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:

  • Adjusting the username and password settings.
  • Setting the screen resolution.
  • Configuring color depth.
  • Defining a session timeout value to disconnect inactive sessions automatically.
  • Specifying 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

Configure the firewall to permit remote connections from the public IP address on port 3389, the standard RDP connection port. Follow these steps:

1. In Windows Command Prompt, determine the public IP address by executing the following command:

curl ifconfig.me
cmd output for curl ifconfig.me

If successful, the command will print your IP address.

2. On the remote server, allow access to port 3389 with this 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:

terminal output for sudo ufw allow from your_public_ip/32 to any port 3389.

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

sudo ufw status
terminal output for sudo ufw status.

Test RDP Connection

To check that the server machine was configured properly, let's connect to the Ubuntu system via Remote Desktop from Windows:

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

Windows launching remote connection

2. Paste the remote server's public IP into the Computer box.

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

general settings for Remote desktop connection.

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

4. Click the Connect button. 

RDP connecting in Windows

Note: If you receive an alert stating that Remote Desktop can't connect to the remote computer, ensure that you have enabled the Remote Desktop option in the system settings on the remote server.

5. Hit Yes if you receive the identity verification popup.

6. Enter the remote server's username and password. 

enter credentials to login to the remote server

7. Press Ok.

Once logged in, users can access the Ubuntu Desktop environment:

Ubuntu Remote desktop

Conclusion

After reading this tutorial, you know how to enable RDP using xrdp on Linux. Next, learn all about different server operating systems.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
Windows CMD Commands
January 11, 2023

Windows offers over 280 CMD commands to automate various tasks through the command prompt. Read this guide and grab our free cheat sheet to master the...
Read more
Enable Remote Desktop in Ubuntu
May 16, 2024

Remote Desktop is a useful and user-friendly service allowing you to control another computer remotely. It is excellent for users who prefer having a...
Read more
How to Use SSH to Connect to a Remote Server in Linux or Windows
November 23, 2023

In this tutorial, find out How To Use SSH to Connect to a Remote Server in Linux or Windows...
Read more
CLI vs. GUI: What Are the Differences?
February 1, 2023

The CLI and GUI both serve the same purpose of facilitating the users' interaction with the OS. Read this article to learn the key differences between the two UIs...
Read more