How to Setup RDP on Ubuntu 20 or higher for Remote Access

RDP (Remote Desktop) Ubuntu
5/5 - (17 votes)

Set up Remote Desktop Protocol (RDP) on your Ubuntu 20, 22 or 24 server to use a graphical desktop from anywhere. This guide walks you through installing a desktop environment and the XRDP server, then connecting to your Ubuntu machine remotely.

Whether you manage a remote server or work on a virtual machine (VM), a graphical interface can make many tasks easier. With RDP access, you connect to the Ubuntu desktop from your local computer. Below we cover each part of setting up RDP access on an Ubuntu 20, 22 or 24 server: installing a desktop environment, setting up XRDP and configuring the connection.

Prerequisites to Set Up RDP on Ubuntu

  • A remote Ubuntu 20.x, 22.x or 24.x server or VM
  • A valid IP address for remote access
  • Basic knowledge of Linux commands
  • A configured SSH client to access the server initially

High-Level Steps to Set Up RDP Access

  1. Update your server so all packages are current.
  2. Install a desktop environment (GNOME, KDE Plasma or Xfce).
  3. Install and configure XRDP to enable RDP support.
  4. Adjust the firewall to allow RDP traffic.
  5. Connect to your Ubuntu desktop with an RDP client.

Why XRDP?

XRDP is an open-source RDP server that is compatible with Microsoft’s RDP protocol. It is lightweight, easy to install and works well on Ubuntu. If more than one desktop environment is installed on the server, XRDP also lets users switch between them.

Step-by-Step Guide to Enable RDP Access

Follow these steps to set up RDP access on your Ubuntu 24.04 server.

1. Update Your System

Start by refreshing the package lists and upgrading outdated packages, so the desktop environment and XRDP install cleanly. Log in via SSH and run the following command:

sudo apt update && sudo apt upgrade -y

2. Install a Desktop Environment

GNOME (recommended):  sudo apt install ubuntu-gnome-desktop -y

3. Install and Configure XRDP

XRDP accepts remote connections over the RDP protocol, which gives you access to the server’s desktop environment.

Install XRDP:

sudo apt install xrdp -y

Add the xrdp user to the ssl-cert group. This is required for secure connections.

sudo adduser xrdp ssl-cert

4. Configure the Firewall

Make sure your server’s firewall allows traffic on port 3389, which XRDP uses.

sudo ufw allow 3389/tcp
sudo ufw reload

RDP traffic can now reach your server. Keep the firewall tight by opening only the ports you need.

6. Create a New User for RDP Access

For secure RDP access, create a dedicated user. Here we create a user named avanetco with a password for RDP logins. Note: SSH login with a password will not work for this user, because password login is disabled for SSH.

6.1. Create the New User with a Home Directory and Bash Shell

Use the following command to create the avanetco user with a home directory and /bin/bash as the default shell:

sudo useradd -m avanetco –shell /bin/bash

6.2. Set a Password for the New User

sudo passwd avanetco

6.3. Grant Sudo Access to the New User (Optional)

sudo usermod -aG sudo avanetco

Access Ubuntu Desktop via Microsoft RDP

When the setup is complete, follow these steps to connect to your Ubuntu desktop from a Windows machine:

  1. Open the Microsoft Remote Desktop Client (Remote Desktop Connection on Windows).
  2. Enter your server’s IP address: type the IP address of your Ubuntu server and select “Connect.”
  3. Log in with your username and password: enter your Ubuntu credentials when prompted.
  4. Select a desktop environment (if applicable): if several desktop environments are installed, XRDP lets you choose one for the session.

Related articles

nslookup practical commands

Anyone who works in IT has run into a failed DNS request at least once, and it can be frustrating. In this…

How to install docker on Linux

Docker has become an essential part of many projects because of the flexibility and advantages it gives a development team. In this…