20.04 XRDP KDE Plasma connect issue

I am very new to Ubuntu and I just installed Ubuntu 20.04 LTS today and trying to setup XRDP so that I can remote -in into my Ubuntu machine from Windows
I executed the following steps:

sudo apt install xrdp 

I then tried all of these but only one at-a-time

sudo apt-get install kde-full
sudo apt-get install kde-desktop
sudo apt-get install kde-standard
sudo apt-get install kde-plasma-desktop

echo "startkde"  > ~/.xsession


sudo systemctl restart xrdp

when I try to connect, I get the login screen from xrdp and I select xorg and enter my username and password.
But then RDP session ends immediately

Can someone please help me set up XRDP and figure out what might be the issue? I can’t stand gnome desktop. I would like to have KDE with XRDP.

Thanks

Asked By: Andy Johnson

||

Install Kubuntu 20.04 LTS

If you prefer KDE, it is better to install the Kubuntu desktop, rather than Ubuntu desktop plus the KDE desktop. This is because the Ubuntu desktop comes with Gnome and its default set of applications. When you install KDE desktop on top the Ubuntu desktop KDE brings in its own set of default applications. This creates unnecessary bloat and occasionally conflicts.

XRDP is hard to setup with Gnome Desktop

I don’t know enough to tell you why this is, but I have learnt from experience that they don’t work out of the box. Someone has written a script to get XRDP to work with the standard Ubuntu desktop. You may check it out if you decide to stay with the Ubuntu desktop and XRDP.

Warning: As with any script, read the script carefully and understand what exactly it does before deciding to use it on your computer.

Hope it helps

Answered By: user68186

This is how I configure XRDP for KDE-Plasma (works on my Ubuntu 20.04)

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

Set session to plasma:

echo "/usr/bin/startplasma-x11" > ~/.xsession

variables for xsessionrc:

export D=/usr/share/plasma:/usr/local/share:/usr/share:/var/lib/snapd/desktop
export C=/etc/xdg/xdg-plasma:/etc/xdg
export 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

If you have plasma installed, you can also login, and execute this on a console:

echo $XDG_SESSION_DESKTOP
echo $XDG_DATA_DIRS
echo $XDG_CONFIG_DIRS

to see if your values are the same.

Now to avoid the "authentication-required"-dialog:

cat <<EOF | 
  sudo tee /etc/polkit-1/localauthority/50-local.d/xrdp-NetworkManager.pkla
[Networkmanager]
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
[Networkmanager]
Identity=unix-group:sudo
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=auth_admin
ResultActive=yes
EOF
sudo systemctl restart polkit

Partial credits:

In case of error:

~/.xsession-errors
/var/log/xrdp-sesman.log
/root/.xsession-errors

or just change the default-session-manager:

sudo update-alternatives --config x-session-manager

To allow root-access, go to /etc/pam.d/sddm and comment out this line:

auth    required        pam_succeed_if.so user != root quiet_success

2021 Update/Note:

Latest version of Windows 10 comes with an SSH client (and server).
So you can now natively tunnel your RDP-session over internet from a windows-box.
(I guess this is why we want xrdp in the first place)
So to do this, create a ssh-key:

ssh-keygen -t rsa -b 4096

With this command, ssh-keygen generates an RSA public-key in

C:Users<USERNAME>.sshid_rsa.pub

along with id_rsa (private key)

Now append the content of id_rsa.pub (text-file) to

~/.ssh/authorized_keys 

in your linux box (this allows ssh-login for the user with home-directory ~ with the rsa-private-key and validates with the rsa-public-key – only copy the public key!)

Then your can open a ssh-connection with port-forwarding:

ssh YOUR_USER_NAME@71.44.33.22 -C -L 1234:127.0.0.1:3389

(replace 71.44.33.22 with your ip/domain)
Now you can connect with mstsc to 127.0.0.1:1234 which gets forwarded to 71.44.33.22:3389. 3389 is the default-xrdp-port.

Please validate that the ssh-login works in the first place, before you try to connect with mstsc.

Also, if you do this, please consider your rsa-keys as compromised, as Microsoft is a surveillance company. Don’t do this for serious stuff. !
You have now been warned !
That said, your private Linux box is most-likely nothing that warrants this kind of seriousness.

Note on Syntax:

ssh  %user%@%servername-or-ip% -L %LocalPort%:127.0.0.1:%RemotePort%

-C for compression (argh, the speed, the speed).

You can also save the remote desktop session connection settings to a file, e.g. "C:Program FilesConnectionsComputername"

together with a connect.bat with content

start cmd /k ssh username@71.44.33.22 -C -L 1234:127.0.0.1:3389
REM cd "C:Program FilesConnectionsComputername"

REM START has a peculiarity involving double quotes 
REM around the first parameter. 
REM If the first parameter has double quotes 
REM it uses that as the optional TITLE for the new window.
start "" "C:Program FilesConnectionsComputernamecomputername.rdp"

Create a shortcut for the .bat file on the desktop with icons from C:WindowsSystem32mstsc.exe or C:WindowsSysWOW64mstsc.exe.

Best Linux program to connect to XRPD is remmina (IMHO).
To install:

sudo apt-get install software-properties-common
sudo apt-add-repository ppa:remmina-ppa-team/remmina-next
sudo apt-get update && sudo apt-get install remmina remmina-plugin-rdp libfreerdp-plugins-standard

Update 2021:

Remmina is crap (performance, keyboard layout).
Just use KRDC, which is in the repos BY DEFAULT.


** Update 2023: **

If you want the x-session to terminate when the connection is severed, you can start Plasma with dbus.
To do so, just add

dbus-launch --exit-with-session startplasma-x11 

to .xsession.
Note that if you are running apt dist-upgrades over XRPD, this might be a bad idea, though.

Answered By: WitchCraft
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.