Add xrdp (Windows Remote Desktop) on Ubuntu 18.04 LTS Server


apt update
apt install xubuntu-desktop xrdp
adduser xrdp ssl-cert
mv /etc/xdg/autostart/light-locker.desktop /etc/xdg/autostart/light-locker.desktop.bak
reboot


cp -f /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
cp -f /etc/xrdp/sesman.ini /etc/xrdp/sesman.ini.bak
sed -i "s/autorun=/autorun=Xorg/g" /etc/xrdp/xrdp.ini
sed -i "0,/allow_channels=true/{s/allow_channels=true/allow_channels=false/}" /etc/xrdp/xrdp.ini


# update-alternatives --config x-session-manager
There are 3 choices for the alternative x-session-manager (providing /usr/bin/x-session-manager).
  Selection    Path                    Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gnome-session   50        auto mode
  1            /usr/bin/gnome-session   50        manual mode
  2            /usr/bin/startxfce4      50        manual mode
  3            /usr/bin/xfce4-session   40        manual mode

Press <enter> to keep the current choice[*], or type selection number: 3


[Globals]
#change port if you want
port=3389
...


...
# Comment on the two lines
#test -x /etc/X11/Xsession && exec /etc/X11/Xsession
#exec /bin/sh /etc/X11/Xsession

# Add following 4 lines
unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
. $HOME/.profile
xfce4-session


systemctl restart xrdp


Ref

https://gist.github.com/jpwhite3/80007c752f09b52737d9b86dbf54daa9

https://askubuntu.com/questions/1063481/lightlocker-and-xscreensaver-conflicting

https://unix.stackexchange.com/questions/367294/how-do-i-change-my-default-session

https://lapina.tistory.com/147