11.12.2024

How to configure xRDP server on Ubuntu 18.04

This tutorial describes how to set up an xRDP server to connect to Ubuntu 18.04 with the lightweight graphical Xforce UI using the RDP protocol. This can be very handy when you need to connect to Linux operating systems with graphical interface from Windows using Remote Desktop.

What is xRDP?

xRDP is Microsoft's free and open-source implementation of RDP (Remote Desktop Protocol) which allows non-Microsoft Windows operating systems (such as Linux and BSD) to provide a fully functional RDP-compatible remote desktop.

Installation and Setup

Connect to your ubuntu server via SSH and perform a system update:

sudo apt-get update
sudo apt-get upgrade -y

Install and enable the xRDP utility:

sudo apt-get install xrdp
sudo systemctl enable xrdp
sudo systemctl restart xrdp

Xrdp service running

Install the xfce environment:

sudo apt-get install xfce4 xfce4-terminal

Open RDP port to be able to connect remotely:

sudo ufw allow 3389/tcp

Reboot the xRDP server for the changes to take effect:

sudo /etc/init.d/xrdp restart

Connecting to an Ubuntu Server via RDP

If you don't know the IP address of the Ubuntu server, you can check it by entering the command:

ifconfig -a

ifconfig output

In our test case it is 10.0.0.2. To connect open the Windows Remote Desktop Connection (mstsc.exe). Enter the IP address of the server and click Connect:

RDP window

A security warning will appear. Click Yes:

RDP certificate warning

In the opened window, select Xorg as the session, enter the username and password for the user and click OK:
Attention: If you are connecting via xRDP, you need to specify a password and root user name. If you are connecting via SSH, you will need the key or password that was configured during the creation of the server in the cloud.

Xrdp authentication window

This will connect to the xforce desktop.

Xforce desktop

If it shows a black screen when connecting to xrdp you need to go into the /etc/xrdp folder, and make changes to the startwm.sh file.

sudo nano /etc/xrdp/startwm.sh

We need to add:

unset DBUS_SESSION_BUS_ADDRESS

unset XDG_RUNTIME_DIR

Before the line:

test -x /etc/X11/Xsession && exec /etc/X11/Xsession

startwm.sh settings

After making the changes you have to restart the XRDP service:

sudo systemctl restart xrdp

Now you can run mstsc.exe again and connect to our ubuntu server.