Xrdp

From ArchWiki
Jump to navigation Jump to search

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.

xrdp checks only if a session with the same geometry is already opened. It will start a new session if the geometry/resolution does not match.

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 graphical acceleration by installing xorgxrdp-glamorAUR for Intel and AMD GPUs and xorgxrdp-nvidiaAUR for Nvidia GPUs.

Running with Vino (GNOME VNC Server for root session)

Enable the server to be seen via vino-preferences. Since vino defaults to port 5900 for connections, we will edit the xrdp configuration file to understand this. Append the vino session to xrdp's configuration file:

/etc/xrdp/xrdp.ini
[xrdp8]
name=Vino-Session
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=5900

If you encounter VNC connection errors, it may be because vino-server defaults to accepting only TLS connections. This must be changed to standard VNC authentication so that xrdp may connect:

gsettings set org.gnome.Vino require-encryption false

You can also restrict vino-server to only listen on the loopback interface:

gsettings set org.gnome.Vino network-interface lo

Remember to restart the xrdp server, and one should be able to connect to the vino session (tested using xfreerdp).

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, try adding dbus-run-session to your ~/.xinitrc file. For example, for KDE Plasma, use exec dbus-run-session 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

If you are prompted to login to gnome-keyring when your session starts add the following 2 lines to /etc/pam.d/xrdp-sesman

auth        optional    pam_gnome_keyring.so
session     optional    pam_gnome_keyring.so auto_start

Prevent autostart items from starting

To prevent user defined ~/.config/autostart items for a 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

Install pulseaudio-module-xrdpAUR. If that does not work, it could be a symptom of an issue with loginctl, so try that fix above. If it still does not work add pulseaudio & to your ~/.xinitrc.

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.