Nanohost logo
PricingFAQ
Log inSign Up

Remote Desktop Protocol Using xrdp on Ubuntu 22.04

Tutorials

15 Aug 2025

Remote Desktop Protocol Using xrdp on Ubuntu 22.04 full

The Remote Desktop Protocol (RDP) is a Microsoft-developed network protocol that enables users to remotely access and control the graphical interface of a Windows server. It operates on a client-server model: an RDP client runs on your local device, while the RDP server runs on the remote machine.

While RDP is primarily used for Windows, you can also connect to the graphical interface of a Linux server using xrdp, an open-source RDP server implementation.

In this guide, you’ll learn how to install and configure xrdp on an Ubuntu 22.04 server to enable Remote Desktop access. We’ll cover setting up a lightweight desktop environment, configuring the firewall, testing connections from Windows, macOS, and Linux, optimizing performance, supporting multiple users, and handling Wayland/Xorg compatibility.

Key moments

  • xrdp enables RDP access to Ubuntu: You can set up and configure xrdp on an Ubuntu 22.04 server to allow remote desktop access via the standard RDP protocol from Windows, macOS, or Linux clients.
  • Xfce is recommended for performance: Using a lightweight desktop environment such as Xfce ensures a responsive graphical interface with minimal resource consumption during RDP sessions.
  • Firewall configuration is essential: To permit RDP connections, TCP port 3389 must be opened in the server’s firewall, ideally restricted to specific IP addresses for enhanced security.
  • Each user requires a .xsession file: Every Linux user account must have a .xsession file defining the session (e.g., xfce4-session) to properly start the desktop environment over RDP.
  • Multiple users can connect simultaneously: xrdp supports concurrent sessions, with each user having an isolated environment, as long as system resources allow and accounts are set up correctly.
  • Wayland is not fully compatible with xrdp: For stable operation, xrdp requires Xorg. If the system uses Wayland, it must be disabled (for example, through gdm3 settings).
  • Performance can be optimized for slow connections: Lowering screen resolution and color depth, turning off desktop effects, and enabling client-side compression can greatly improve performance on low-bandwidth networks.
  • Alternative tools are available: Depending on your requirements, solutions like VNC, TeamViewer, or X2Go may provide better performance, features, or compatibility for Linux remote desktop access.

Requirements

To complete this tutorial, you will need:

  • One Ubuntu 22.04 server with a non-root user with sudo privileges, a firewall, and at least 2GB of RAM, which you can buy on nanohost.org if you don't have one yet
  • A local computer with an RDP client installed. A list of available RDP clients for different operating systems is provided below:
    • On Windows, you can use the default Remote Desktop Connection application.
    • On macOS, you can use the Microsoft Remote Desktop application.
    • On Linux, you can use FreeRDP, or Remmina.

Step 1 — Installing a Desktop Environment on Ubuntu

By default, Ubuntu Server provides only a terminal interface. To use a graphical user interface (GUI) over RDP, you’ll need to install a desktop environment.

For this setup, you’ll install Xfce, a lightweight and user-friendly desktop environment for Linux.

1. Connect to your server via SSH and update the package list:

sudo apt update

2. Install Xfce and additional tools:

sudo apt install xfce4 xfce4-goodies -y

3. During installation, you’ll be asked to choose a display manager (the program that handles graphical logins and sessions).

  • For a lightweight setup, lightdm is recommended.
  • This guide will use gdm3, but you may choose lightdm if you prefer.

4. Once the desktop environment is installed, you can proceed with installing xrdp to enable Remote Desktop access.

Step 2 — Installing xrdp on Ubuntu

xrdp is an open-source Remote Desktop Protocol (RDP) server for Linux, allowing remote desktop connections from RDP clients on Windows, macOS, or Linux.

1. Install xrdp:

sudo apt install xrdp -y

2. Check the service status:

sudo systemctl status xrdp

If the installation was successful, the status should show active (running).

Output ● xrdp.service - xrdp daemon
     Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: **active (running)** since Sun 2022-08-07 13:00:44 UTC; 26s ago
       Docs: man:xrdp(8)
             man:xrdp.ini(5)
   Main PID: 17904 (xrdp)
      Tasks: 1 (limit: 1131)
     Memory: 1016.0K
     CGroup: /system.slice/xrdp.service
             └─17904 /usr/sbin/xrdp

3. Start the service manually if needed:

sudo systemctl start xrdp

Then verify the status again to ensure it’s running.

With xrdp installed and running, you’re ready to configure it to accept remote connections from clients.

Step 3 — Configuring xrdp and Updating the Firewall

The main xrdp configuration file is located at /etc/xrdp/xrdp.ini. It defines global settings, logging options, channel parameters, and available session types.

1. Edit the configuration file:

sudo nano /etc/xrdp/xrdp.ini
  • Globals — global server settings.
  • Logging — log file settings.
  • Channels — supported RDP channel parameters.
  • Session types — configurations for each supported session type, such as [Xorg] or [Xvnc].

By default, the username and password parameters are set to ask, prompting the user for credentials during connection. For initial use, the default configuration is sufficient. Save and close the file.

2. Set the default session manager:

echo "xfce4-session" | tee ~/.xsession

This ensures that xfce4-session is used when logging in over RDP. Without this file, the graphical session will fail to start.

3. Restart xrdp:

sudo systemctl restart xrdp

4. Allow RDP through the firewall:

curl ifconfig.me
  • Allow access to port 3389 from your IP (replace your_local_ip):
sudo ufw allow from your_local_ip/32 to any port 3389
  • Verify the firewall status:
sudo ufw status

Port 3389 is now open for RDP connections from your IP address.

Step 4 — Testing the RDP Connection

With xrdp installed and configured, you can now test the connection from your local machine.

On Windows

1. Open the Remote Desktop Connection app.

2. In Computer, enter your server’s public IP.

3. In User name, enter your server username (click Show Options if the field is hidden).

4. Click Connect.

If you see a connection error, ensure port 3389 is open in the firewall and xrdp is running.

5. When prompted for identity verification, click Yes.

6. Enter your server username (e.g., sammy) and password, then click OK.

After successful login, you’ll see your Ubuntu desktop environment.

You can close the RDP session at any time by clicking the Exit button.

Testing the RDP Connection on macOS

To connect from macOS, you will use the Microsoft Remote Desktop application, available for free in the Mac App Store.

1. Install and open the Microsoft Remote Desktop app. You can download it directly from the Mac App Store.

2. Add your remote server:
• Click Add PC.
• In the PC name field, enter your server’s public IP address.


3. Configure the user account
(optional):
• Under User account, you can add your username and password now, so you won’t have to enter them every time you connect.
• If you skip this step, the app will prompt you for your credentials when you connect.


4. Start the connection:
• Select the newly created connection and click Start (or double-click it).
• If an identity verification popup appears, click Yes to continue.

5. Log in to your Ubuntu server:
• If prompted, enter your Ubuntu username (e.g., sammy) and password.
• Click OK to proceed.

6. Access the desktop. After a few seconds, you should see your Ubuntu desktop environment via RDP.

When finished, you can close the session by clicking the Exit button in the Microsoft Remote Desktop app.

Testing the RDP Connection on Linux

To connect from Linux, you will need an RDP client. In this example, you’ll use Remmina, a free and open-source remote desktop client.

1. Install Remmina (on Ubuntu or Debian-based systems):

sudo apt install remmina
  • If prompted, type y to confirm.
  • For other Linux distributions, check the Remmina documentation for installation instructions.

2. Launch the application

3. Set up the connection:

  • In the RDP box, enter your server’s public IP address.
  • Press Enter to connect.


4. Log in:

  • Enter your Ubuntu username (e.g., sammy) and password.
  • Select the session type (e.g., Xorg).
  • Click OK to proceed.

5. Unlock the desktop (if prompted). You may need to enter your password again to unlock the remote desktop.

6. Access the Ubuntu desktop. After logging in, your remote Ubuntu desktop environment will appear.

When finished, close the RDP session using the Exit button.

Once you’ve verified that the connection works, you can repeat this process any time you need graphical access to your remote server.

FAQs

1. Can I use xrdp to connect from Windows to Ubuntu?
Yes. Once xrdp is installed and configured on your Ubuntu server, you can connect from Windows using the built-in Remote Desktop Connection app. Simply enter the server’s public IP address in the Computer field to start an RDP session.

2. What port does xrdp use?
By default, xrdp listens on TCP port 3389, the standard RDP port. Ensure this port is open in your firewall and accessible from the client machine.

3. Why do I get a black screen after logging in via RDP?
A black screen usually points to a misconfigured session. Common causes include:

  • Missing or incorrect ~/.xsession file.
  • Unsupported or incompatible desktop environment.
  • Wayland conflicts (switch to Xorg).
  • Permission issues in the user’s home directory.
    Switching to a lightweight desktop environment like Xfce and verifying your .xsessionsetup often resolves the issue.

4. Is xrdp secure for remote access?
RDP includes built-in encryption, but you should add extra layers of security:

  • Limit port 3389 access in your firewall (UFW, iptables, or cloud firewall).
  • Restrict access to specific IP addresses.
  • Use strong passwords and disable root login.
  • Tunnel RDP through SSH or use a VPN for production environments.

5. How do I change the desktop environment for xrdp?
Update your ~/.xsession file to start a different desktop environment. For example, to use LXDE:

echo "startlxde" > ~/.xsession

Make sure the environment is installed and restart the xrdp service:

sudo systemctl restart xrdp


6. Do I need to open any firewall ports for xrdp?
Yes. Open TCP port 3389 for RDP connections. To allow only your IP:

sudo ufw allow from {your_ip_address}/32 to any port 3389

Replace {your_ip_address} with your public IP.

7. Can multiple users connect to the same server with xrdp?
Yes. Each user needs their own Linux account and .xsession file. xrdp provides isolated sessions for each user, and limits can be adjusted in /etc/xrdp/sesman.ini.

8. How do I fix authentication errors in xrdp?
Possible causes include:

  • Wrong username or password.
  • Missing .xsession file.
  • Misconfigured desktop environment.
  • Incorrect file permissions.
    Make sure the user exists, .xsession is set correctly, and permissions are proper:
chmod 755 ~/
chown : ~/.xsession
how-tolinuxbasics

Read also

How to Reboot Linux Now (Safely): systemctl reboot, shutdown -r now, and Force-Reboot Options

How to Reboot Linux Now (Safely): systemctl reboot, shutdown -r now, and Force-Reboot Options

Tutorials

Whether you’re applying kernel updates, clearing a stuck device, or finishing a configuration change, a reboot is sometimes the cleanest fix. This guide shows beginner-friendly and safe ways to restart Linux immediately (“reboot now Linux”), plus how to force reboot if the system is unresponsive. We’ll cover desktops, servers, and remote machines over SSH.

Linux Navigation and File Management

Linux Navigation and File Management

Tutorials

Learning how to move around and manage files and folders in the Linux filesystem is one of the most important skills for working with any computer. On cloud servers, these tasks are usually done through the terminal using well-known Linux shells and standard commands. This guide will walk you through some of the essential skills needed to work with files and directories from the terminal.

Linux Essentials: Step-by-Step Guides

Linux Essentials: Step-by-Step Guides

Tutorials

Learn the basics of the Linux terminal — what it is, how the shell and command prompt work, and how to run your first commands.

Products

Server in the United StatesServer in the United KingdomServer in NetherlandsServer in SingaporeServer in Poland

NOVPS CLOUD LTD ©2025