How to enable RDP using xrdp on Ubuntu 22.04
Prerequisites
- Ubuntu 22.04 server
- Windows client to RDP
- Sudo access
1. Login into the Ubuntu server and open up the terminal

2. Run the following commands
sudo apt update
sudo apt install xfce4 xfce4-goodies -y
You will be prompted to choose a display manager. In this guide, we'll use gdm3
3. Install xrdp
sudo apt install xrdp -y
Verify the installation by entering the below command. It should show as active (running)
sudo systemctl status xrdp

If the status is not running, you may need to restart the service manually using this command:
sudo systemctl start xrdp
4. Review & configure xrdp settings
Open the configuration file with this command:
sudo nano /etc/xrdp/xrdp.ini
The section you may be interested in would be the session types. username and password are set to "ask". This can be modified if necessary

The next part is to create a file in the user's home directory. This file is used as a session manager upon graphical login request
cd ~
echo "xfce4-session" | tee .xsession
sudo systemctl restart xrdp
5. Configure firewalls (Optional)
This may be required if you cannot RDP due to firewall restrictions. Additionally, this step is useful if you want to restrict IP ranges to your network
sudo ufw allow from your_local_ip/32 to any port 3389
sudo ufw enable
sudo ufw status

If for whatever reason you need to remove these rules, you can do so as follow:
- sudo ufw status numbered

2. sudo ufw delete [number]

6. Test RDP Connection from Windows.
- Open Remote Desktop Connection

- You will be prompted with a security warning which you can ignore. Press Yes to continue

- Enter your username and password

You should now be able to access your ubuntu desktop environment

Notes to keep in mind:
- If you have another session open, it will fail to log in and the windows will exit. Simply log off the other session and try again to resolve
Found this article useful? Why not buy Phi a coffee to show your appreciation?