How to Install Remote Desktop (Xrdp) on Ubuntu 24.04


Remote Desktop Protocol (RDP) is usually associated with Windows, but you can use it with Linux too. By installing a tool called Xrdp on your Ubuntu 24.04 server, you can turn it into an RDP server. This lets you connect to your server’s graphical desktop from a local machine using an RDP client.

This guide will cover the steps for setting up Xrdp as an RDP server on your Ubuntu 24.04 server. We’ll also cover how to use an RDP client to connect with a local machine system. This will give you remote access and control over your Linux server’s desktop environment.

Table of Contents:

1. How to Install Xrdp on Ubuntu 24.04

To install Xrdp on Ubuntu 24.04 you will need a desktop environment on a Linux server. Once the desktop environment is set up, then you can install the Xrdp server on Ubuntu using the default apt package manager. After the installation, you have to connect a remote desktop client to confirm the connection.

The RDP uses the Client-Server model for its connections. In this tutorial, the Ubuntu 24.04 system will act as a server while the Windows system will act as a remote client.

The following are the prerequisites for this installation guide:

  • A working Ubuntu server with a desktop environment installed.
  • You must have Sudo or root privileges for your system.
  • A local computer having Windows and RDP client installed (For testing purposes)

Now we will cover all these installation steps of Xrdp in detail.

2. Installing Xrdp Server on Ubuntu

Before you proceed with the installation of the desktop environment, first update your system packages:

sudo apt update

By default, Ubuntu comes with the terminal environment only. To access the Ubuntu server from the RDP client, you will need a desktop environment installed. We will install the Xfce desktop environment on our Ubuntu 24.04 server. Xfce is a minimalistic desktop environment.

Run this command to get the Xfce on Ubuntu 24.04:

sudo apt install xfce4 xfce4-goodies -y

After you install the Xrdp you will be prompted to select the display manager for RDP client connection. Press enter and continue.

Now, you can select whichever display manager is installed on your system. We are going to continue with the gdm3 display manager.

Finally, run this command to install the Xrdp server on your Ubuntu 24.04 system:

sudo apt install xrdp -y

To check if the Xrdp is installed and running, you can run the systemctl command:

sudo systemctl status xrdp

If the status is Active and green, it means the Xrdp is successfully installed. Press Q to exit this.

Otherwise, you can manually enable and start the Xrdp on Ubuntu 24.04 using this command:

sudo systemctl start xrdp

3. Configure Xrdp on Ubuntu

The xrdp.ini file is the default file that stores all the configuration needed for an RDP connection. It is an editable file located at /etc/xrdp/xrdp.ini. By default, Xrdp works without requiring changes to a configuration file. However, if you’re looking to modify your RDP connection, you can edit this file to fit your specific needs.

To modify this file, open it using any text editor:

sudo nano /etc/xrdp/xrdp.ini

The Xrdp configuration file is organized into several sections:

  • Global Settings: This section controls general aspects of how Xrdp operates, like the address it listens to for connections.
  • Logging: This section defines how Xrdp records information about its activity.
  • Channels: This section specifies how Xrdp handles different data streams used during a remote desktop session (like keyboard input or clipboard sharing).
  • Session Types: Each supported way to display your desktop remotely (like using the X Window System or a virtual VNC session) has its dedicated section with specific settings. These sections are named after the session type, for example, Xorg or XVnc.

Note: The configuration file itself doesn’t have a separate Session Types heading. This functionality is mentioned as a comment to help users understand how session types are defined.

For the initial configuration, we are going to continue with the default setups.

Once you have modified the xrdp.ini file according to your needs, you can exit the editor.

Creating XRDP User to SSL-Cert Group

After creating, you need to add this user to the SSL-Cert group. This group handles and secures the client-server connection by securing the socket layers. These layers are used for verifying and communicating between Xrdp client and server.

To add the Xrdp user, run:

sudo adduser xrdp ssl-cert

The above command grants the XRDP service read access to the certificates managed by that group.

Exporting Environment Variables

Next, you need to export environment variables while setting up XRDP on Ubuntu because, by default, XRDP sessions and regular shell sessions (like SSH) handle environment variables differently.

If you don’t export these environment variables, you will be unable to access Ubuntu from RDP on Windows. The RDP client will show a black screen.

To export the environment variables, create a file using the Nano or any other editor.

You can create any of one file from the following two:

sudo nano .xsessionrc

Here we have created the xsessionrc file, but you can also create the following file and place the environment variable for exporting.

sudo nano /etc/xrdp/startwm.sh

After creating the file, place the following two lines inside the file and exit the nano editor:

export GNOME_SHELL_SESSION_MODE=ubuntu

export XDG_CURRENT_DESKTOP=ubuntu:GNOME

These environment variables ensure that when you connect via XRDP, you get the full Ubuntu GNOME experience rather than a generic GNOME session.

Now restart the Xrdp service to apply all the changes:

sudo systemctl restart xrdp

Finally, reboot your system so all of your session settings get updated along with the environment variables that we exported in the above steps.

4. Configure System Firewall

Next, you have to configure the system firewall settings. You must enable the port 3389 remote connection from a public IP. This is the standard port used for the RDP connections.

First, check your public IP address using the client machine. Open Windows Command Prompt and run the below command to get your public IP:

ipconfig

Note down the IPv4, as this will be needed to allow access to port 3389. Try with IPv4, if it does not work for you, try adding IPv6.

Now head over to the remote server (Ubuntu 24.04) and allow access to port 3389 using this command:

sudo ufw allow from your_public_ip/32 to any port 3389

Remember to replace your public IP which you got from the Client computer in the above command.

Note: If you want to allow all the requests to port 3389 you can run the sudo ufw allow 3389/tcp command. You can also try running the sudo ufw allow from any to any port 3389 proto tcp command.

Now reload the ufw firewall to apply all the changes:

sudo ufw reload

Finally, verify the ufw configuration using this command:

sudo ufw status

Note: If your status is showing inactive, then first enable the ufw using the sudo ufw enable command.

5. Testing the RDP Connection

To check if the Ubuntu server is ready and can be connected from the client’s computer, we will test the RDP connection.

Follow these short steps to configure the RDP client with the Ubuntu 24.04 server.

Step 1: First open your System settings on Ubuntu 24.04 and select Remote Desktop.

Step 2: Here, make sure the Remote Control and Remote Desktop options are enabled. Also, note down the Username and password, as you will need these two to log in from RDP and connect with the Ubuntu server computer. The default username and password is modifiable.

Step 3: Now open the client’s Windows computer and look for the app in the start menu or search for Remote Desktop Connection.

Step 4: Paste the public IP address of the Ubuntu machine into the Computer field and click the Connect button to start the RDP connection.

A security popup might appear. Click Yes to proceed if you trust the connection.

To get the Public IP of the Ubuntu 24.04 system, run the ifconfig command.

Similarly, you can also get your IP from network settings.

Note: If you have installed Ubuntu 24.04 on the virtual box, then make sure to set your network adapter settings to Bridged Adapter. Otherwise, you will end up getting the wrong IP address, and you will be unable to connect from the client’s computer.

Step 5: Before proceeding further, make sure to Log Out from your Ubuntu system. Otherwise, RDP on Windows (Client) will keep on crashing.

Step 6: Finally the RDP window will open up, type your Ubuntu username and password in the respective fields.

Step 7: Upon successful login, you’ll be granted access to the Ubuntu desktop environment.

6. Uninstalling Xrdp from Ubuntu 24.04

To uninstall the Xrdp you can use the apt package manager. First, open the terminal and run this command to uninstall the Xrdp package:

sudo apt remove xrdp

This will remove the Xrdp package and its core dependencies.

If you have installed Xrdp using any other method like compiling it from source, you’ll need to remove the files manually. First, identify the installation location. It might be in /usr/local/sbin/ or similar. Remove the Xrdp binary and configuration files. Also delete any remaining directories associated with Xrdp (e.g., /etc/xrdp).

7. Testing the RDP Connections on macOS and Linux Systems

Like Windows, you can also connect to the Xrdp server through macOS and Linux systems. For macOS, install Microsoft Remote Desktop Connection software. For Linux systems, you can install the Remmina. It is an open-source client for Linux systems. This will work as a client for your Linux Ubuntu server.

To install Remmina on Ubuntu, run this command:

sudo apt install remmina

The procedure for connection of the Ubuntu server with macOS and Linux client is similar to Windows. You just need the public IP of your Ubuntu server and connect with the Ubuntu server as described in the above steps.

Conclusion

Xrdp is an open-source software that works like a Microsoft RDP server for non-Windows operating systems. It allows remote connection to your Linux machine through RDP-compatible tools. On Ubuntu 24.04 the apt will help you in Xrdp server installation. Once the installation is done, you have to configure the local IP address and allow the port from firewall settings. After that, you can connect your Ubuntu 24.04 server with the Windows client computer using the Xrdp.

Print Friendly, PDF & Email
Categories