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.
- 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.
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
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.
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
2. Confirm the installation with:
sudo systemctl status xrdp
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.
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.
sudo vim /etc/xrdp/xrdp.ini
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
1. In Windows Command Prompt, determine the public IP address by executing the following command:
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
[your_public_ip] with the output obtained from the previous command:
3. Verify the UFW (Uncomplicated Firewall) configuration is correct and port 3389 is now set to accept connections:
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.
2. Paste the remote server's public IP into the Computer box.
3. Type in the username in the User name box.
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.
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.
7. Press Ok.
Once logged in, users can access the Ubuntu Desktop environment:
After reading this tutorial, you know how to enable RDP using xrdp on Linux. Next, learn all about different server operating systems.