Xrdp

From ArchWiki

xrdp is a daemon that supports Microsoft's Remote Desktop Protocol (RDP). It uses Xvnc or xorgxrdp as a backend.

Installation

Install the xrdpAUR package (or alternatively xrdp-gitAUR for the development version). This only supports Xvnc as the backend.

Xorg backend

To use xorgxrdp instead for the backend, install the xorgxrdpAUR package.

Add allowed_users=anybody to /etc/X11/Xwrapper.config to allow anybody to start an X server.

Usage

First, start the xrdp service. You should be able to connect an RDP client to the host on the default RDP port (3389). If successful, you will be greeted with the xrdp session manager window which allows you to choose between Xorg or Xvnc sessions and provides inputs for user authentication. The session manager UI can be highly customized by modifying /etc/xrdp/xrdp.ini.

The parameters used to start Xorg and Xvnc display servers can be configured in /etc/xrdp/sesman.ini.

After successfully starting a display server, xrdp will execute /etc/xrdp/startwm.sh by default. This script is meant to start a window manager (similar to .xinitrc) and will read from ~/.xinitrc or /etc/X11/xinit/xinitrc if they exist. It is recommended to edit ~/.xinitrc to start your desktop environment or window manager, but you can also edit /etc/xrdp/startwm.sh.

If you just close the session window and RDP connection, you can access the same session again next time you connect with RDP. When you exit the window manager or desktop environment from the session window, the session will close and a new session will be opened the next time.

Tips and tricks

Autostart at boot

The xrdpAUR package contains service files for systemd. Enable xrdp.service.

Graphical acceleration

For Xorg sessions, you can enable OpenGL and Vulkan graphical acceleration by installing xorgxrdp-glamorAUR for Intel and AMD GPUs and xorgxrdp-nvidiaAUR for Nvidia GPUs.

Sound

Install the necessary PulseAudio modules with pulseaudio-module-xrdpAUR.

Troubleshooting

Black box around cursor

If you encounter black box around mouse pointer create ~/.Xresources-xrdp with line Xcursor.core:1 and load it in ~/.xinitrc like

xrdb ~/.Xresources-xrdp
exec startlxde

You may need to install xorg-xrdb.

Black screen

You may get a black screen after logging into the session manager if your ~/.xinitrc has --exit-with-session set in the dbus_args.

Try copying ~/.xinitrc to ~/.xrdpinitrc, removing --exit-with-session, and updating /etc/xrdp/startwm.sh to call ~/.xrdpinitrc instead of ~/.xinitrc. You might need to append your desktop environment to the call to .xrdpinitrc, as is mentioned in ~/.xinitrc; eg. . ~/.xrdpinitrc xfce.

Black screen with a desktop environment

If you get a black screen and you use a desktop environment, it may be a result of D-Bus not being properly initialized. Try running the desktop environment with dbus-launch --exit-with-session in your ~/.xinitrc file. For KDE Plasma, you can use the command /usr/lib/plasma-dbus-run-session-if-needed startplasma-x11.

loginctl or systemctl --user not working

Try commenting out all the references to systemd-home in /etc/pam.d/system-auth. See this issue.

Prompts for gnome-keyring or KDE Wallet

If you are prompted to login to gnome-keyring or [KDE Wallet] when your session starts, modify the file /etc/pam.d/xrdp-sesman as follows:

/etc/pam.d/xrdp-sesman
#%PAM-1.0

auth            include         system-remote-login
-auth           optional        pam_gnome_keyring.so
-auth   optional  pam_kwallet5.so

account         include         system-remote-login

password        include         system-remote-login
-password       optional        pam_gnome_keyring.so use_authtok

session         optional        pam_keyinit.so force revoke
session         include         system-remote-login
-session                optional        pam_gnome_keyring.so auto_start
-session  optional  pam_kwallet5.so auto_start

If you only use gnome-keyring it is not necessary to include the kwallet5 lines, and vice versa.

Prevent autostart items from starting

To prevent user defined ~/.config/autostart items from starting you can set the autostart directory param on the session in the ~/.xinitrc to use only the global /etc/xdg/autostart directory.

get_session(){
    local dbus_args=(--sh-syntax)
    case "$SESSION" in
        awesome) dbus_args+=(awesome) ;;
        bspwm) dbus_args+=(bspwm-session) ;;
        budgie) dbus_args+=(budgie-desktop) ;;
        cinnamon) dbus_args+=(cinnamon-session -a /etc/xdg/autostart) ;;

No sound

This could be a symptom of an issue with loginctl, so try that fix above. The following error may be encountered in the system journal:

Failed to load module "module-x11-publish" (argument: "display=:10.0 xauthority="): initialization failed.

This is the result of systemd improperly starting PulseAudio. One workaround is to disable the user unit files pulseaudio.service and pulseaudio.socket either for your own user or for all users, and make PulseAudio start when needed by setting autospawn to yes in /etc/pulse/client.conf.

If sound still does not work, try manually starting PulseAudio with pulseaudio & in your ~/.xinitrc.

Two-finger scrolling is too fast

Use the xorg backend, make sure xorgxrdp is 0.9.19 or newer. Then add XRDP_XORG_TOUCHPAD_SCROLL_HACK=yes to the [SessionVariables] section of /etc/xrdp/sesman.ini.

See this issue for details.

See also

  • TigerVNC - VNC, an alternative to RDP, also used as backend here.
  • freerdp a rdesktop fork that supports RDP 7.1 features including network level authentication (NLA). It primarily consists of the xfreerdp client. In addition, the freerdp-shadow-cli command provides a quick and easy way to start an RDP server.