How to Install xrdp Server for Remote Desktop on Ubuntu 18.04

This guide provides step-by-step instructions to install and configure the xrdp server for remote desktop access on Ubuntu 18.04. xrdp is an open-source implementation of the Microsoft Remote Desktop Protocol (RDP), allowing you to access a graphical desktop remotely from Windows, macOS, or Linux clients.

Prerequisites

  • Ubuntu 18.04 server with a non-root user with sudo privileges.

  • At least 2GB of RAM for a smooth desktop experience.

  • A local machine with an RDP client (e.g., Remote Desktop Connection on Windows, Remmina on Linux, or Microsoft Remote Desktop on macOS).

  • A stable internet connection.

Step-by-Step Installation

Step 1: Update the System

Ensure your system is up to date to avoid package conflicts and ensure security.

sudo apt update && sudo apt upgrade -y

Step 2: Install a Desktop Environment

Ubuntu servers typically lack a GUI, so install a lightweight desktop environment like Xfce for optimal performance with xrdp.

sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils -y
  • xfce4: Core Xfce desktop environment.

  • xfce4-goodies: Additional plugins for enhanced functionality.

  • xorg, dbus-x11, x11-xserver-utils: Required for the graphical interface.

During installation, you may be prompted to select a display manager. Choose lightdm for compatibility with xrdp (alternatively, gdm3 can be used, but lightdm is preferred).

Step 3: Install xrdp

Install the xrdp package to enable RDP functionality.

sudo apt install xrdp -y

Verify that the xrdp service is running:

sudo systemctl status xrdp
  • Look for active (running) in the output. If it’s not running, start it:

sudo systemctl start xrdp
  • Enable xrdp to start on boot:

sudo systemctl enable xrdp

Step 4: Configure xrdp

  1. Set the Desktop Environment: Configure xrdp to use the Xfce desktop by creating or editing the ~/.xsession file for the user who will connect remotely:

    echo xfce4-session > ~/.xsession

    Set proper permissions:

    chmod 755 ~/ && chown $USER:$USER ~/.xsession
  2. Support Multiple Users (Optional): To allow multiple simultaneous user sessions, edit the xrdp start script:

    sudo sed -i.bak '/fi/a #xrdp multiple users configuration \n xfce4-session \n' /etc/xrdp/startwm.sh

    Restart xrdp to apply changes:

    sudo systemctl restart xrdp
  3. Add xrdp User to SSL Group (for secure connections):

    sudo adduser xrdp ssl-cert

Step 5: Configure the Firewall

xrdp uses port 3389 by default. If using UFW, allow traffic on this port:

sudo ufw allow from <your_ip_address>/32 to any port 3389

Replace <your_ip_address> with your client’s public IP (e.g., 192.168.1.100). For local networks, allow the subnet:

sudo ufw allow from 192.168.1.0/24 to any port 3389

Reload the firewall:

sudo ufw reload

Verify the rule:

sudo ufw status

Step 6: Test the xrdp Connection

  1. From Windows:

    • Open Remote Desktop Connection (type mstsc in the Windows search bar).

    • Enter the Ubuntu server’s IP address and click Connect.

    • At the xrdp login screen, select Session: Xorg, enter your Ubuntu username and password, and click OK.

    • You should see the Xfce desktop.

  2. From macOS:

    • Install Microsoft Remote Desktop from the Mac App Store.

    • Add a new connection, enter the server’s IP address, and provide your Ubuntu credentials.

  3. From Linux:

    • Use an RDP client like Remmina or Vinagre.

    • Connect to the server’s IP address, select Xorg as the session, and log in.

Step 7: Optimize Performance (Optional)

  • Reduce Screen Resolution and Color Depth: Lower display settings in your RDP client for better performance on slow connections.

  • Disable Desktop Effects: In Xfce, disable animations via Settings Manager > Window Manager Tweaks.

  • Enable Compression: Enable compression in your RDP client to reduce bandwidth usage.

Troubleshooting Common Issues

  • Black Screen: Ensure no user is logged into the console locally, as xrdp does not support mirroring active sessions. Log out of the local session before connecting.

  • Authentication Errors: Verify the username, password, and ~/.xsession file permissions.

  • Connection Refused: Confirm xrdp is running (sudo systemctl status xrdp) and port 3389 is open (sudo netstat -tulnp | grep 3389).

  • Slow Performance: Reduce resolution, disable Wayland (edit /etc/gdm3/custom.conf, set WaylandEnable=false, then sudo systemctl restart gdm3), or use Xfce.

  • Multi-User Issues: Ensure the /etc/xrdp/startwm.sh script includes the Xfce session configuration.

Notes

  • Security: For public servers, use a VPN or restrict firewall access to specific IPs. Enable TLS in /etc/xrdp/xrdp.ini for encryption.

  • Alternatives: Consider VNC, TeamViewer, or X2Go if xrdp performance is inadequate.

  • Wayland Incompatibility: xrdp requires Xorg. Switch to Xorg if Wayland is enabled (see troubleshooting).

For further details, visit the official xrdp GitHub page

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top