Here’s a Step-by-Step Guide How to Enable Remote Desktop Protocol Using XRDP on Ubuntu 22.04
1. Update Your System
Before installing any new packages, ensure your method is up-to-date. Open your terminal & execute the following commands:
bash Copy code sudo apt update sudo apt upgrade
This will refresh the system package list and install any available updates.
2. Install XRDP
Ubuntu 22.04’s package repository includes XRDP, so you can install it easily using the apt package manager:
bash Copy code
sudo apt install xrdp -yThis command installs XRDP and any required dependencies. Once the installation completes, XRDP should start automatically. You can verify this with the following order:
bash Copy code
sudo systemctl status xrdpIf it’s running, you’ll see an active status, indicating that XRDP is ready for configuration.
3. Allow XRDP Through the Firewall
To access your Ubuntu system remotely, you’ll need to open port 3389, which is the default port for XRDP. You can configure this using ufw, Ubuntu’s default firewall tool:
bash Copy code
sudo ufw allow 3389/tcpAfter configuring the firewall, it’s a good idea to check the firewall status to confirm that the port is open:
bash Copy code
sudo ufw statusYou should see a rule allowing traffic on port 3389.
4. Install a Desktop Environment (If Needed)
If you’re using a server version of Ubuntu or if you didn’t choose a graphical desktop during installation, you’ll need to install a desktop environment. The popular choice for Ubuntu is GNOME, but you can also use lightweight options like XFCE, which is resource-friendly and pairs well with XRDP.
To install XFCE, use the following command:
bash Copy code
sudo apt install xfce4 xfce4-goodies -yOnce installed, configure XRDP to use XFCE as the default session.
5. Configure XRDP to Use the Desktop Environment
After installing the desktop environment, you’ll need to configure XRDP to use it. Open the XRDP configuration file:
bash Copy code
sudo nano /etc/xrdp/startwm.shIn this file, find the lines towards the end that look like this:
bash Copy code
. /etc/X11/XsessionComment out this line by adding a # in front, and then add the following lines to specify XFCE as the session:
bash Copy code # . /etc/X11/Xsession startxfce4
After making these changes, save the file and close the editor (for nano, press Ctrl + X, then Y, and then Enter).
6. Restart XRDP Service
To appeal the changes, restart the XRDP service:
bash Copy code
sudo systemctl restart xrdpThis command will reload XRDP with the new configuration, and it will now start an XFCE session when you connect.
7. Verify XRDP User Access
By default, XRDP should work with any user account on your Ubuntu system. If you want to restrict access, create a new user account specifically for remote desktop sessions:
bash Copy code
sudo adduser yourusernameThen, add this user to the “ssl-cert” group to ensure that XRDP has the required permissions:
bash Copy code
sudo adduser yourusername ssl-certThis step can help improve security by limiting who can connect via XRDP.
8. Connecting to Ubuntu 22.04 via XRDP
Now that XRDP is installed and configured, you can access your Ubuntu 22.04 system remotely. From a Windows machine, open the Remote Desktop Connection application (RDP), which is available by default on Windows. Enter the IP address of your Ubuntu system and the port (3389), like this:
plaintext Copy code
192.168.x.x:3389Replace 192.168.x.x with your Ubuntu system’s IP address. After connecting, you should see the XRDP login screen where you can enter your username and password. Select “OK” to log in.
9. Troubleshooting Common XRDP Issues
While XRDP is relatively straightforward to set up, you may run into common issues that can affect functionality. Here’s how to troubleshoot a some of them:
- Black Screen Issue: If you see a black screen after logging in, it’s often due to misconfiguration or missing files. Make sure that the desktop environment is properly set up and that /etc/xrdp/startwm.sh is configured to start xfce4.
- Session Management Conflicts: If you’re having conflicts between sessions (e.g., local and remote sessions overlapping), consider logging out of the desktop environment on your Ubuntu machine before initiating an XRDP session.
- Permission Issues: XRDP requires access to certain certificates, which is why adding your user to the ssl-cert group is necessary. Ensure that permissions are correctly set for access.
- Firewall and Network Settings: If you’re unable to connect, ensure that port 3389 is open on both your firewall and router if accessing from an external network.
10. Enhancing Security for XRDP Connections
Securing your XRDP session is crucial, especially if connecting over the internet. Here are some recommended steps:
- Use SSH Tunneling: One way to secure XRDP is by using SSH tunneling, which encrypts the RDP session. You can achieve this by setting up an SSH server on Ubuntu and creating a tunnel with an SSH client.
- Restrict IP Addresses: Configure ufw to allow RDP access only from specific IP addresses.
- Change Default XRDP Port: Instead of using the standard 3389 port, change it to something unique to reduce the likelihood of automated attacks.
- Install Fail2Ban: Fail2Ban monitors failed login attempts and can block IP addresses with repeated unsuccessful login attempts. Install it on Ubuntu with the seeing:
bash Copy code
sudo apt install fail2ban -yAfter installation, configure Fail2Ban to monitor XRDP logs, adding an extra security layer.
Conclusion
Enable Remote Desktop Protocol using XRDP on Ubuntu 22.04 can make remote access simple and efficient, especially when paired with a desktop environment like XFCE. By following these steps and incorporating additional security measures, you can safely and effectively manage your Ubuntu system remotely. From system updates and firewall configurations to SSH tunneling and Fail2Ban, each element contributes to a secure and seamless remote desktop experience.



