How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (2024)

The author selected the COVID-19 Relief Fund to receive a donation as part of the Write for DOnations program.

Introduction

Remote Desktop Protocol (RDP) is a network protocol developed by Microsoft that allows users to remotely access and interact with the graphical user interface of a remote Windows server. RDP works on the client-server model, where an RDP client is installed on a local machine, and an RDP server is installed on the remote server.

RDP is widely used for Windows remote connections, but you can also access and interact with the graphical user interface of a remote Linux server by using a tool like xrdp, an open-source implementation of the RDP server.

In this tutorial, you will install and configure an RDP server using xrdp on a Ubuntu 22.04 server and access it using an RDP client from your local machine. You will understand how to establish access to a remote Linux server by configuring and using an RDP connection.

Prerequisites

To complete this tutorial, you will need:

  • One Ubuntu 22.04 server with a non-root user with sudo privileges, a firewall, and at least 1GB of RAM, which you can set up by following the Ubuntu 22.04 initial server setup guide.

  • A local computer with an RDP client installed. A list of available RDP clients for different operating systems is provided below:

Step 1 — Installing a Desktop Environment on Ubuntu

In this step, you will install and configure a desktop environment on your Ubuntu server. By default, an Ubuntu server comes with a terminal environment only. A desktop environment will need to be installed to access a user interface.

From the available options for Ubuntu, you will install the Xfce desktop environment. Xfce offers a lightweight, user-friendly desktop environment for Linux-based systems.

To begin, connect to your server using SSH and update the list of available packages using the following command:

  1. sudo apt update

Next, install the xfce and xfce-goodies packages on your server:

  1. sudo apt install xfce4 xfce4-goodies -y

You will be prompted to choose a display manager, which is a program that manages graphical login mechanisms and user sessions. You can select any option from the list of available display managers, but this tutorial will use gdm3.

After installing the desktop environment, you will now install xrdp on your server.

Step 2 — Installing xrdp on Ubuntu

xrdp is an open-source implementation of the RDP server that allows RDP connections for Linux-based servers. In this step, you will install the xrdp on your Ubuntu server.

To install xrdp, run the following command in the terminal:

  1. sudo apt install xrdp -y

After installing xrdp, verify the status of xrdp using systemctl:

  1. sudo systemctl status xrdp

This command will show the status as active (running):

Output

● xrdp.service - xrdp daemon Loaded: loaded (/lib/systemd/system/xrdp.service; enabled; vendor preset: enabled) Active: **active (running)** since Sun 2022-08-07 13:00:44 UTC; 26s ago Docs: man:xrdp(8) man:xrdp.ini(5) Main PID: 17904 (xrdp) Tasks: 1 (limit: 1131) Memory: 1016.0K CGroup: /system.slice/xrdp.service └─17904 /usr/sbin/xrdp

If the status of xrdp is not running, you may have to start the service manually with this command:

  1. sudo systemctl start xrdp

After executing the above command, verify the status again to ensure xrdp is in a running state.

You have now installed xrdp on your server. Next, you will review the xrdp configuration to accept connections from remote clients.

Step 3 — Configuring xrdp and Updating Your Firewall

In this step, you will review the default configuration of xrdp, which is stored under /etc/xrdp/xrdp.ini, and add a configuration for an RDP connection. You will also update the firewall settings.

xrdp.ini is the default configuration file to set up RDP connections to the xrdp server. The configuration file can be modified and customized to meet the RDP connection requirements.

Open the file in nano text editor or any editor of your choice:

  1. sudo nano /etc/xrdp/xrdp.ini

The configuration file contains different sections:

  • Globals defines some global configuration settings for xrdp.
  • Logging defines logging subsystem parameters for logs.
  • Channels defines multiple channel parameters that RDP supports.
  • Session types defines multiple supported session types by xrdp. Every session type configuration is defined as a separate section under its session type name enclosed in square brackets, such as [Xorg] and [XVnc]. There is no [Sessions types] heading in the file; instead, it is written as a comment.

In the configuration file, navigate to the Session types section. You will find multiple supported session types and their parameters listed:

Output

...;; Session types;; Some session types such as Xorg, X11rdp, and Xvnc start a display server.; Startup command-line parameters for the display server are configured; in sesman.ini. See and configure also sesman.ini.[Xorg]name=Xorglib=libxup.sousername=askpassword=askip=127.0.0.1port=-1code=20[Xvnc]name=Xvnclib=libvnc.sousername=askpassword=askip=127.0.0.1port=-1#xserverbpp=24#delay_ms=2000[vnc-any]...[neutrinordp-any]......

By default, the username and password parameters are set to ask, which means the user will be prompted to enter their username and password to connect over RDP. Parameters, such as name, username, and password, can be modified if necessary. For the initial RDP connection to the server, the default configuration will suffice.

Save and close the file when finished.

Now move to your user’s home directory if you are not there already:

  1. cd ~

Next, you will create a .xsession file under /home/sammy and add the xfce4-session as the session manager to use upon login:

  1. echo "xfce4-session" | tee .xsession

tee writes the echoed string "xfce4-session" to the file .xsession. The above configuration ensures that xfce4-session is used as a session manager upon graphical login request. As a result of installingxfce as your desktop environment, xfce4-session serves as its session manager. If you don’t include this information in the .xsession file, no session manager is chosen, and the RDP session will fail to connect to the graphical display.

Restart the xrdp server:

  1. sudo systemctl restart xrdp

Next, you will configure your firewall to allow remote connections from your public IP on port 3389. An RDP connection serves on TCP/IP port 3389. To access the remote server over RDP, you must allow port 3389 in your firewall.

First, find the public IP for your local machine:

  1. curl ifconfig.me

On Windows, use the Windows Command Prompt to run this command.

curl places a request on ifconfig.me that returns your public IP as an output:

Output

...your_local_ip

Next, allow access to the RDP port 3389 on your remote server, replacing your_local_ip with the output of the last command:

  1. sudo ufw allow from your_local_ip/32 to any port 3389

Verify the status of your UFW firewall:

  1. sudo ufw status

The output should look like the following:

Output

Status: ActiveTo Action From-- ------ ----OpenSSH ALLOW Anywhere 3389 ALLOW your_local_ip OpenSSH (v6) ALLOW Anywhere (v6) ...

You have now enabled port 3389 to accept connections from your public IP. Next, you will test your local machine’s RDP connection to your remote server.

Step 4 — Testing the RDP Connection

In this step, you will test the RDP connection from your local machine. The sections below include actions for testing the connection on Windows, macOS, and Linux machines.

Testing the RDP Connection on Windows

To test the connection using the Remote Desktop Connection client on Windows, first launch the Remote Desktop Connection app.

Enter your remote server’s public IP and username into the fillable text boxes for Computer and User name. You may need to press the down arrow for Show Options to input the username:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (1)

Press the Connect button. If you receive an alert that the Remote Desktop can't connect to the remote computer, check that you have turned on the Remote Desktop option in your system settings.

Press Yes if you receive the identity verification popup:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (2)

Then, enter your remote server’s username (sammy) and the password you created for user sammy during the initial server setup. Press Ok.

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (3)

Once you have logged in, you should be able to access your Ubuntu Desktop environment:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (4)

Using RDP, you successfully connected to your remote Ubuntu server from your local machine. You can close it with the exit button when you have finished using your graphical desktop.

Testing the RDP Connection on macOS

To test the connection using the Remote Desktop Connection client on macOS, first launch the Microsoft Remote Desktop Connection app.

Press Add PC, then enter your remote server’s public IP in the fillable box:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (5)

You can Add a user account when setting up the connection:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (6)

If you do not add a user during setup, you will be prompted for your user login credentials:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (7)

Press Yes to bypass the identity verification popup:

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (8)

Once you have logged in, you can access your Ubuntu remote desktop. You can close it with the exit button when you have finished using your graphical desktop.

Testing the RDP Connection on Linux

You will need an RDP client to test the RDP connection on a local Linux machine. First, install the remmina RDP client for Ubuntu:

  1. sudo apt install remmina

Select y if prompted to complete the installation. This command will install Remmina, an open-source remote desktop client on your Ubuntu system using apt. For other Linux distributions, you can review the Remmina documentation for installation.

Once installed, launch the remmina application on your local Linux machine and enter your remote server’s public IP in the fillable box. Press Enter on your keyboard to connect to your remote desktop.

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (9)

Then, enter your remote server’s username (for this tutorial, the username is sammy) and the password you created for the user during the initial server setup. Press Ok.

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04 | DigitalOcean (10)

You may need to enter your user’s password again to unlock the remote desktop.

Once you have logged in, you should be able to access your Ubuntu Desktop environment.

Using RDP, you successfully connected to your remote Ubuntu server from your local machine. You can close it with the exit button when you have finished using your graphical desktop.

Once you have ensured the remote connection works, you can use this sequence whenever you need to use the graphical interface for your remote Linux server.

Conclusion

In this article, you configured xrdp to connect to a graphical desktop for your remote Ubuntu server over an RDP connection from a local machine.

Now, you can try configuring a VNC connection for your Linux server with How to Install and Configure VNC on Ubuntu 20.04. VNC is another option for remote connection to a Linux desktop.

How To Enable Remote Desktop Protocol Using xrdp on Ubuntu 22.04  | DigitalOcean (2024)

FAQs

How to enable Remote Desktop in Ubuntu 22.04 command line? ›

Gnome Remote Desktop (RDP/VNC on Ubuntu 22.04 and other recent versions) can be enabled through command line by using the grdctl command. The command line parameters are documented in the man pages of the cli tool, e.g. here.

How to enable Remote Desktop in Ubuntu desktop? ›

Share your desktop
  1. Open the Activities overview and start typing System.
  2. Select Settings ▸ System from the results. ...
  3. Select Remote Desktop to open the panel.
  4. To let others view your desktop, set the Remote Desktop switch to on. ...
  5. To let others interact with your desktop, set the Remote Control switch to on.

How to check xrdp status in Linux? ›

XRDP-MultiUser-Installation
  1. Update Environment. $ sudo apt-get update. ...
  2. Install XRDP. $ sudo apt install xrdp.
  3. Check status of XRDP: ( XRDP runs automatically after installation) $ sudo systemctl status xrdp.
  4. add the xrdp user to the ssl-cert group. $ sudo adduser xrdp ssl-cert.
  5. Restart xrdp service: ...
  6. Configuring Firewall.

How to RDP from Ubuntu terminal? ›

Set up Ubuntu for RDP clients
  1. Open a terminal session by tapping Ctrl+Alt+T.
  2. Update your packages with this command sudo apt update.
  3. Enter your password.
  4. Install XRDP, a remote desktop server for Linux with the command: sudo apt install xrdp -y.
Feb 28, 2024

How to enable Remote Desktop? ›

When you're ready, select Start > Settings > System > Remote Desktop, and turn on Enable Remote Desktop.

How to connect xrdp? ›

Step-by-Step Guide for Connecting to xRDP
  1. Open your Remote Desktop Client: To connect, use a remote desktop client on your local machine. ...
  2. Specify the User Credentials: Enter the username and password of the account on your Linux server for the remote session.
Jan 18, 2024

How to enable Remote Desktop with command? ›

If you want to use this method, follow the steps below.
  1. Press the Win + R keys together, enter the CMD command, and click OK.
  2. On the new screen, input the command mstsc /v: computername. Replace Computer Name with the name of the remote PC.
  3. Now press the Enter Key.
Oct 9, 2023

What is RDP and xrdp? ›

xrdp is a free and open-source implementation of Microsoft RDP (Remote Desktop Protocol) server that enables operating systems other than Microsoft Windows (such as Linux and BSD-style operating systems) to provide a fully functional RDP-compatible remote desktop experience.

How do I enable Remote Desktop in Linux? ›

Configuring Linux for Remote Access
  1. Click on the icons that are at the far-right of the system menu bar and click Settings.
  2. In the Settings window, select Sharing and click on the top switch button to enable the service.
  3. Click Remote Desktop.
  4. Enable Remote Desktop (click on the switch).

How do I restart xrdp in Ubuntu? ›

Restart the xrdp server: sudo systemctl restart xrdp.

What port is xrdp? ›

The Xrdp operates on port 3389 by default for the RDP protocol.

How to use remmina in Ubuntu? ›

Launch Remmina from the application menu or by typing remmina in the terminal. Click on the “+” icon in the top-left corner to add a new connection profile. Choose the desired protocol from the dropdown menu (e.g., RDP, VNC, SSH). Fill in the required connection details such as server address, username, and password.

How to connect to Remote Desktop using SSH in Ubuntu? ›

To access your Ubuntu system remotely, use the SSH command from another machine. your_username is the username on the Ubuntu system you're accessing. your_server_ip is the IP address of your Ubuntu system. port_number is the SSH port configured on your Ubuntu system (default is 22).

What is the default port for RDP in Ubuntu? ›

Changing the default RDP port (3389) to a non-standard port can enhance security, protecting against simple network scans and brute-force attacks.

What is the command for RDP in terminal? ›

MSTSC is the command that you need to use to open Windows Remote Desktop in the command prompt. You can type MSTSC directly in to the search box on Windows 10 (or click on Start > Run in earlier Windows versions).

How do I start Remote Desktop from command line? ›

MSTSC is the command that you need to use to open Windows Remote Desktop in the command prompt. You can type MSTSC directly in to the search box on Windows 10 (or click on Start > Run in earlier Windows versions). You can also use the MSTSC command directly from the command line as well.

How to turn on Remote Desktop in Linux? ›

Enable Remote Desktop

In the Settings window, select Sharing and click on the top switch button to enable the service. Click Remote Desktop. Enable Remote Desktop (click on the switch). Select Enable Legacy VNC Protocol.

How do I unlock remote login in Ubuntu? ›

Open the Settings app to the System page. Click Remote Desktop. Click Remote Login. Unlock the page.

How to enable SSH in Ubuntu? ›

How to enable SSH on Ubuntu
  1. Open Terminal.
  2. Update your repository: sudo apt update.
  3. Enter your password.
  4. Install OpenSSH: sudo apt install openssh-server -y.
  5. Enter your password.
  6. The SSH server will start running automatically.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 5977

Rating: 4.9 / 5 (49 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.