How to Enable RDP in Ubuntu 22.04

How to Enable Remote Desktop Protocol (RDP) in Ubuntu 22.04

To enable Remote Desktop Protocol (RDP) in Ubuntu 22.04, you need to install and configure an RDP-compatible server such as xrdp, which allows Windows and other RDP clients to connect to your Ubuntu system. You can do this by updating your system packages, installing xrdpsudo apt install xrdp -y, enabling and starting the xrdp service, and then allowing it through the firewall. Once configured, you can connect from a Windows PC using the built-in Remote Desktop Connection client by entering your Ubuntu machine’s IP address and login credentials.

Why Use RDP in Ubuntu 22.04?

Ubuntu 22.04 offers several methods to access a machine remotely, such as SSH or VNC. However, RDP has its advantages:

  • Better Performance: RDP offers a more seamless experience with reduced latency and optimized connection performance.
  • Cross-Platform Support: RDP can be used to connect Ubuntu from both Linux and Windows machines.
  • Graphical Interface: Unlike SSH, which is command-line-based, RDP provides access to the full graphical desktop environment, making it ideal for users who prefer a visual interaction.

Now, let’s jump into how you can enable and configure RDP on Ubuntu 22.04.

Step-by-Step Guide to Enable RDP on Ubuntu 22.04

1. Update Your System

Before you start with the installation, it’s always a good idea to make sure your system is up-to-date with the latest software and security patches. Open the terminal and run the following commands:

bash   Copy code
sudo apt update
sudo apt upgrade

This will ensure that all your packages are up to date and your system is secure.

2. Install XRDP (RDP Server)

Ubuntu doesn’t come with an RDP server pre-installed, so the next step is to install XRDP, a free and open-source implementation of the Remote Desktop Protocol. You can install XRDP via the terminal using the following command:

bash   Copy code
sudo apt install xrdp

After installing, XRDP will automatically start. You can check if it is running with the seeing command:

bash   Copy code
sudo systemctl status xrdp

The output should show that XRDP is “active” or “running.”

3. Configure XRDP

Next, we need to configure XRDP to work with the Ubuntu 22.04 graphical desktop environment. By default, XRDP uses the Xfce desktop environment, but if you’re using GNOME (the default desktop environment in Ubuntu 22.04), we will need to make a slight adjustment.

Edit the XRDP configuration file:

bash   Copy code
sudo nano /etc/xrdp/startwm.sh

Before the last two lines that look like this:

bash   Copy code
. /etc/X11/Xsession

Add the following line to ensure GNOME is loaded:

bash   Copy code
gnome-session

Press Ctrl + X, then Y, & Enter to save & exit.

Restart the XRDP service for the change to accept effect:

bash   Copy code
sudo systemctl restart xrdp

4. Allow RDP through the Firewall

For external devices to connect to your Ubuntu machine via RDP, you need to allow the RDP port (3389) through the system firewall. If you’re using UFW (Uncomplicated Firewall), you can configure the firewall by executing the following commands:

bash   Copy code
sudo ufw allow 3389/tcp
sudo ufw reload

If UFW is not installed on your system, you can install it and enable it with these commands:

bash   Copy code
sudo apt install ufw
sudo ufw enable

5. Verify Desktop Environment Compatibility

XRDP supports different desktop environments. Ubuntu 22.04 defaults to GNOME, but depending on your preferences, you can install and use a lighter desktop environment like Xfce for a smoother experience, especially if you are working with limited resources.

Install Xfce (optional but recommended for better performance):

bash   Copy code
sudo apt install xfce4 xfce4-goodies

After installation, edit the XRDP configuration to set Xfce as the default desktop:

bash   Copy code
echo "xfce4-session" > ~/.xsession

Restart XRDP once again:

bash   Copy code
sudo systemctl restart xrdp

6. Connect to Ubuntu from Windows Using RDP

Once XRDP is installed and configured, you can use the Windows Remote Desktop Client to connect to your Ubuntu machine.

Steps to Connect:

  1. On your Windows machine, open the Remote Desktop Connection application. You can find this by typing “Remote Desktop Connection” in the Start menu search bar.
  2. In the Computer field, enter the IP address of your Ubuntu machine and click Connect.
  3. You will be prompted to enter your username & password. Use the credentials of the user account on your Ubuntu machine.
  4. After clicking OK, the RDP session will establish, and you will see your Ubuntu desktop.

Learn More: How to Use Windows Remote Desktop to Connect to Ubuntu

7. Connect to Ubuntu from Linux Using RDP

You can also connect to Ubuntu from another Linux machine using the Remmina client, which supports RDP, VNC, SSH, and other protocols.

Steps to Connect:

  1. Install Remmina on your Linux machine using the terminal:
    bash   Copy code
    sudo apt install remmina remmina-plugin-rdp
  2. Open Remmina from the applications menu.
  3. In the new connection profile, select RDP as the protocol and enter the IP address of your Ubuntu machine.
  4. Enter your Ubuntu username and password, then click Connect. You should now be able to see and interact with the Ubuntu desktop.

8. Secure Your XRDP Connection

RDP connections over the internet can be vulnerable to attacks. Here are a few steps to enhance the security of your remote desktop connection:

  • Use SSH tunneling to encrypt your RDP session. You can use SSH to forward the RDP traffic over an encrypted tunnel. This will add a layer of security to the connection.
  • Change the default RDP port from 3389 to something less common to reduce the risk of automated attacks. You can do this by editing the /etc/xrdp/xrdp.ini file:
bash   Copy code
sudo nano /etc/xrdp/xrdp.ini

Change the default port from 3389 to another available port (e.g., 3390):

bash   Copy code
port=3390

Restart the XRDP service to attach the changes:

bash   Copy code
sudo systemctl restart xrdp
  • Enable UFW logging to monitor connection attempts:
bash   Copy code
sudo ufw logging on

By applying these security measures, you can reduce the risk of unauthorized access to your machine.

Conclusion

Setting up RDP on Ubuntu 22.04 using XRDP provides a smooth, graphical interface that allows you to connect to and control your Ubuntu desktop remotely. Whether you’re connecting from Windows or another Linux machine, this method offers flexibility and ease of use.

While the installation and setup are straightforward, securing your RDP connection is equally important. By following the steps outlined above, you can ensure a stable and secure remote desktop environment.

Enabling RDP on Ubuntu 22.04 gives you the power to access your machine from anywhere, making it a valuable tool for remote work, administration, or personal use.

Scroll to Top