Ubuntu 18.04: Connect to KDE desktop environment via XRDP

This article will describe installing KDE desktop environment and XRDP, and connecting to KDE desktop environment via XRDP.

1 Install KDE desktop environment

Install KDE desktop environment with this.

2 Install XRDP

Install XRDP.

$ sudo apt install -y xrdp
$ sudo sed -e 's/^new_cursors=true/new_cursors=false/g' \
           -i /etc/xrdp/xrdp.ini
$ sudo systemctl enable xrdp
$ sudo systemctl restart xrdp

3 Create ~/.xsession and ~/.xsessionrc

Create .xsession and .xsessionrc in home directory of user to be connected.

$ echo "startkde" > ~/.xsession
$ D=/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop
$ C=/etc/xdg/xdg-plasma:/etc/xdg
$ C=${C}:/usr/share/kubuntu-default-settings/kf5-settings
$ cat <<EOF > ~/.xsessionrc
export XDG_SESSION_DESKTOP=KDE
export XDG_DATA_DIRS=${D}
export XDG_CONFIG_DIRS=${C}
EOF

4 Avoid Authentication Required dialog

Authentication Required dialog will be displayed after XRDP connection is established.

0001_AuthenticationRequired.png

For avoiding Authentication Required dialog, create the following pkla file which will success authentication. You can use unix-user:* as Identity and no as ResultAny which will fail authentication.

$ cat <<EOF | \
  sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-NetworkManager.pkla
[Netowrkmanager]
Identity=unix-group:sudo
Action=org.freedesktop.NetworkManager.network-control
ResultAny=yes
ResultInactive=yes
ResultActive=yes
EOF
$ cat <<EOF | \
  sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-packagekit.pkla
[Netowrkmanager]
Identity=unix-group:sudo
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=auth_admin
ResultActive=yes
EOF
$ sudo systemctl restart polkit

5 Connect to KDE desktop environment via XRDP

Use Xorg as a session type. Windows Remote Desktop Connection is as the following.

0002_xrdp-kde.png