Installing XRDP with XFCE Desktop on Ubuntu 20.04 LTS for Remote Access.
This guide will walk you through the process of setting up XRDP with the XFCE desktop environment on Ubuntu 20.04 LTS, allowing you to remotely access your Ubuntu machine using a Remote Desktop Protocol (RDP) client.
XRDP is an open-source implementation of the Microsoft Remote Desktop Protocol, which allows Linux systems to be remotely controlled via RDP. XFCE is a lightweight desktop environment that works well with XRDP, providing a responsive remote experience.
Prerequisites:
- A fresh installation of Ubuntu 20.04 LTS (Desktop or Server version).
- Sudo privileges on your Ubuntu machine.
- Internet connectivity on your Ubuntu machine.
- An RDP client on your local machine (e.g., Remote Desktop Connection on Windows, Remmina on Linux, Microsoft Remote Desktop on macOS).
Step 1: Update Your System
Before installing any new packages, it's good practice to update your system's package list and upgrade existing packages.
sudo apt update
sudo apt upgrade -y
Step 2: Install XFCE Desktop Environment
If you installed Ubuntu Server, you'll need to install a desktop environment. XFCE is recommended for its lightweight nature, which makes for a smoother remote experience. If you already have Ubuntu Desktop installed, you can skip this step or install XFCE alongside your current desktop.
To install XFCE (the xfce4-goodies package includes many useful plugins and applications for XFCE):
sudo apt install xfce4 xfce4-goodies -y
This command will download and install all necessary XFCE packages. This might take a few minutes depending on your internet connection.
Step 3: Install XRDP
Now, install the XRDP server itself.
sudo apt install xrdp -y
Once installed, the XRDP service will automatically start. You can verify its status:
sudo systemctl status xrdp
You should see active (running) in the output.
Step 4: Configure XRDP to Use XFCE
By default, XRDP might try to use a different desktop environment (like GNOME if it's present). We need to configure it to use XFCE.
First, open the XRDP configuration file using a text editor:
sudo nano /etc/xrdp/xrdp.ini
Find the line that says port=3389 (or port=tcp://:3389) and ensure it's uncommented. You can leave the default port 3389, or change it if necessary.
Now, we need to instruct XRDP to use XFCE. XRDP uses the .xsession file in your home directory to determine which desktop environment to load.
Create or edit the .xsession file in your user's home directory:
echo xfce4-session > ~/.xsession
This command creates a file named .xsession in your current user's home directory and writes xfce4-session into it. This tells XRDP to launch an XFCE session for that user when they connect.
Step 5: Configure XRDP Session Startup Script
We also need to modify the startwm.sh script, which XRDP uses to start the window manager. This is important to ensure the XFCE session starts correctly.
Open the startwm.sh file:
sudo nano /etc/xrdp/startwm.sh
Comment out the following two lines by adding a # at the beginning of each line:
# test -x /etc/X11/Xsession && exec /etc/X11/Xsession
# exec /bin/sh /etc/X11/Xsession
Add the following lines at the end of the file:
startxfce4
This ensures that startxfce4 is executed when an XRDP session begins.
Save the file and exit the editor (Ctrl+X, Y, Enter for Nano).
Step 6: Adjust Firewall Rules (UFW)
If you have UFW (Uncomplicated Firewall) enabled on your Ubuntu machine, you need to allow incoming connections on the RDP port (default 3389).
sudo ufw allow 3389/tcp comment 'XRDP'
sudo ufw enable # if not already enabled
sudo ufw status
The output of sudo ufw status should show 3389/tcp ALLOW Anywhere.
Step 7: Restart XRDP Service
After making configuration changes, restart the XRDP service for the changes to take effect.
sudo systemctl restart xrdp
Step 8: Connect from Your Remote Client
Now you can try connecting to your Ubuntu machine from your local computer using an RDP client.
Open your RDP client.
Enter the IP address of your Ubuntu machine.
When prompted, enter your Ubuntu username and password.
You should now see the XFCE desktop environment loaded.
Troubleshooting Tips
"Authentication required for ...": This can happen if polkit rules are too strict. A quick (but less secure) fix is to allow anyone to authenticate.
sudo nano /etc/polkit-1/localauthority.conf.d/02-allow-colord.conf
Add the following content:
polkit.addRule(function(action, subject) {
if ((action.id == "org.freedesktop.color-manager.create-device" ||
action.id == "org.freedesktop.color-manager.create-profile" ||
action.id == "org.freedesktop.color-manager.delete-device" ||
action.id == "org.freedesktop.color-manager.delete-profile" ||
action.id == "org.freedesktop.color-manager.modify-device" ||
action.id == "org.freedesktop.color-manager.modify-profile") &&
subject.isInGroup("users")) {
return polkit.Result.YES;
}
});
Save and exit, then reboot: sudo reboot.
Blank screen after login: Double-check your .xsession file and startwm.sh configurations for typos. Ensure the startxfce4 command is correct and uncommented, and the default exec lines in startwm.sh are commented out.
Connection refused: Verify XRDP service status (sudo systemctl status xrdp) and firewall rules (sudo ufw status).
Slow performance: Ensure your network connection is stable. XFCE is chosen for its lightness, but a poor network can still cause lag.
This setup provides a functional remote desktop experience to your Ubuntu 20.04 LTS machine using XRDP and XFCE.