Install and Use XRDP on a Raspberry Pi 5

pi install xrdp ssd
,

If you’re looking to remotely access your Raspberry Pi 5 using a graphical desktop environment, XRDP is one of the most convenient tools to set up. XRDP allows you to use the built-in Remote Desktop Protocol (RDP) available on most operating systems like Windows, macOS, and Linux to connect to your Raspberry Pi remotely. In this blog post, I’ll walk you through the steps to install and configure XRDP on a Raspberry Pi 5, so you can easily access it from any device.

Step 1: Update Your Raspberry Pi OS

Before installing any new software, it’s always a good idea to update your Raspberry Pi OS to ensure everything is up-to-date.

Open a terminal on your Raspberry Pi (or SSH into it from another device). Run the following commands to update the package list and upgrade any existing packages:

sudo apt update && sudo apt upgrade

Step 2: Install XRDP

XRDP is available in the default Raspberry Pi OS repository, making installation quite simple. Open a terminal and install XRDP by running the following command:

sudo apt install xrdp

Once installed, the XRDP service will start automatically. You can verify it’s running with:

sudo systemctl status xrdp

You should see a message indicating that XRDP is “active” and running.

Step 3: Connect to the Raspberry Pi via Remote Desktop

Now that XRDP is installed and running, you can connect to your Raspberry Pi using any RDP client. Here’s how:

On Windows:

  1. Open the Remote Desktop Connection app (press Win + R and type mstsc).
  2. Enter the IP address of your Raspberry Pi.
  3. Click Connect.
  4. When prompted, enter your Raspberry Pi’s username and password.
  5. You should now see your Raspberry Pi’s desktop on your Windows PC!
Windows RDP client
Pi5 XRDP logon

On macOS:

  1. Download and install the Microsoft Remote Desktop app from the Mac App Store.
  2. Open the app and click Add PC.
  3. Enter the Raspberry Pi’s IP address and click Save.
  4. Double-click the connection, and when prompted, enter your Raspberry Pi credentials.
  5. You should now see your Raspberry Pi’s desktop.

On Linux:

  1. Install an RDP client like Remmina: sudo apt install remmina
  2. Open Remmina, select RDP, and enter your Raspberry Pi’s IP address.
  3. Connect and enter your credentials when prompted.

Step 4: Managing Authentication Policies

The Raspberry Pi 5 implements a toolkit called Polkit (previously PolicyKit) to define and handle security authorizations. It is used for allowing unprivileged processes to speak to privileged processes. Sessions connected to a Raspberry Pi 5 using console access implement a different authorisation policy to those connected over distributed sessions such as XRDP. This results in authorisation prompts when the system tries to perform an action that requires elevated authorisation:

Raspberry Pi Authentication Prompt

To prevent these authorisation prompts we need to change the authorisation policy for distributed sessions. We can see which policies are used for the package kit system sources (repositories) refresh action using the following command:

pkaction --action-id org.freedesktop.packagekit.system-sources-refresh --verbose
org.freedesktop.packagekit.system-sources-refresh:
  description:       Refresh system repositories
  message:           Authentication is required to refresh the system repositories
  vendor:            The PackageKit Project
  vendor_url:        https://www.freedesktop.org/software/PackageKit/
  icon:              package-x-generic
  implicit any:      auth_admin
  implicit inactive: yes
  implicit active:   yes

The implicit active setting applies to console sessions, so allowing elevated authorisations. The implicit any setting applies to any other session type including XRDP, and required administrator authorisation. We can create a new rule for XRDP to change these settings for the package kit action:

sudo nano /etc/polkit-1/localauthority/50-local.d/10-enable-system-sources-refresh.pkla

Edit the file with the following:

[Allow System Repository Refreshes]
Identity=unix-user:your-username
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes

Save file file then restart the XRDP service:

sudo systemctl restart xrdp

Now the authorisation prompts are not shown anymore. You will need to repeat this exercise for any other unwanted elevated authorisation prompts, such as when performing Wifi Scans when using your Raspberry Pi 5 as an access point.

Step 5: Troubleshooting

XRDP uses a graphics emulator and creates problems for applications relying directly on the Graphics Processing Unit (GPU). Once such application is the Chromium web browser, which fails to display correctly when launched from an RDP session. To fix this, the application should be configured to bypass the GPU. For the Chromium web browser, this means updating the launcher properties:

Chromium browser GPU fix

Adding the --disable-gpu parameter to the command solves the problem.

Different applications will use different approaches for bypassing the GPU.

Another common problem occurs when the user connecting in does not have permission to the GPU device, so we can fix that by removing the reference to the GPU device in the XRDP configuration file:

sudo nano /etc/X11/xrdp/xorg.conf

Look for the Section "Device" and Option "DRMDevice" "/dev/dri/renderD128". Comment out the line and add another with the function name removed:

Section "Device"
    Identifier "Video Card (xrdpdev)"
    Driver "xrdpdev"
#    Option "DRMDevice" "/dev/dri/renderD128"
    Option "DRMDevice" ""
    Option "DRI3" "1"
EndSection

Save the file then reboot.

Step 6: Disconnecting and Reconnecting

To disconnect from the session without shutting down your Raspberry Pi, simply close the RDP client on your device. The session will remain active, and you can reconnect later. If you want to log out of the session completely, use the logout option from the Raspberry Pi desktop menu within your RDP session.

Conclusion

XRDP is an easy and efficient way to access your Raspberry Pi 5 remotely with a full graphical interface, no matter what operating system you’re using. By following these steps, you should be able to install, configure, and use XRDP seamlessly. This setup is especially useful if you’re working on projects or need to monitor your Raspberry Pi without the hassle of plugging in a monitor, keyboard, or mouse.

,

Leave a Comment

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

Scroll to Top