Ubuntu 22 xrdp

$ sudo apt update
$ sudo apt install ubuntu-desktop
$ sudo systemctl enable --now xrdp

$ sudo apt install xrdp 
$ sudo adduser xrdp ssl-cert 
$ sudo systemctl restart xrdp

$ sudo ufw allow 3389
$ sudo ufw reload

錯誤排查

$ cat ~/.xsession-errors

遇到登入黑畫面

$ sudo vim /etc/xrdp/startwm.sh
加上

unset DBUS_SESSION_BUS_ADDRESS
unset XDG_RUNTIME_DIR
        test -z "${LC_MESSAGES+x}" || export LC_MESSAGES
        test -z "${LC_MONETARY+x}" || export LC_MONETARY
        test -z "${LC_NAME+x}" || export LC_NAME
        test -z "${LC_NUMERIC+x}" || export LC_NUMERIC
        test -z "${LC_PAPER+x}" || export LC_PAPER
        test -z "${LC_TELEPHONE+x}" || export LC_TELEPHONE
        test -z "${LC_TIME+x}" || export LC_TIME
        test -z "${LOCPATH+x}" || export LOCPATH
fi

+ unset DBUS_SESSION_BUS_ADDRESS
+ unset XDG_RUNTIME_DIR

if test -r /etc/profile; then
        . /etc/profile
fi

$ sudo systemctl restart xrdp.service