How to work with Xrdp Linux

Updated on:  

What is Linux xrdp?

Xrdp is an open source solution that enables remote access to Linux machines using the Windows remote desktop protocol (RDP). This remote access client for Linux is compatible with multiple remote access clients such as rdesktop, FreeRDP, and NeutrinoRDP.

Prerequisites for running xrdp include:

  • • Installation of the xrdp and xorgxrdp packages;
  • • Firewall configured to allow connections on TCP port 3389.

Xrdp provides access to remotely located Linux machines using any one of several RDP clients. The software establishes the connections via the Microsoft Remote Desktop Protocol (RDP). You can enable remote access through xrdp’s graphical interface with rdesktop, NeutrinoRDP, FreeRDP, or the Microsoft Remote Desktop Client.

In addition to its ability to provide a graphical remote session between a Linux and Windows remote machine, other features of xrdp include:

  • • Drive redirections where you can mount local drives on a remote machine;
  • • Clipboard transfer of files and text between machines;
  • • Audio redirection;
  • • Encrypted RDP transport with TLS.

Establishing a Ubuntu Remote Desktop Server with xrdp

A Linux system running Ubuntu can be configured to act as an RDP server and allow connection to a Windows machine from the remote Linux computer. This can be done using the standard Windows Remote Desktop client which, unfortunately, is not installed as part of most Linux distros. This means you need to install and configure the RDP server manually on the Linux host. Once installation is complete, you can graphically manage a remote Linux machine.

We are going to show you how to configure a Ubuntu 18.04.2 system for access by RDP using the xrdp Linux package.

Using xrdp, machines running operating systems other than Windows can be configured as an RDP server. Setting up a Linux remote desktop with xrdp requires that the X Window System is installed on your computer. The following procedure demonstrates how to set up an xrdp server on a Ubuntu system.

  1. Update the software repository tree with the following command:
    sudo apt-get update

  2. Install the xrdp software from the online repository:
    sudo apt-get install xrdp

  3. The next step involves installing the XFCE desktop environment. GNOME 3 is installed by default with Ubuntu 18, but xrdp will get better performance using the lightweight XFCE alternative. You can still use GNOME to log into the Ubuntu machine locally.

  4. Now it’s time to install XFCE:
    sudo apt-get install xfce4

  5. Create the .xsession file in the user’s home directory and write the xfce4-session string into that file. By doing this, you force the xrdp server to default to the XFCE graphical environment.
    echo xfce4-session > ~/.xsession

  6. Set xrdp to start automatically on system reboot.
    sudo systemctl enable xrdp

  7. Bounce the xrdp service to ensure the changes have taken effect.
    sudo service xrdp restart

  8. Clear the configuration that is stored in the startwm.sh shell script file that is used when starting xrdp:file that is needed to start xrdp:
    sudo sh -c 'cat /dev/null > /etc/xrdp/startwm.sh’

    (You might want to create a copy of the files before clearing it. If so, use this command: cp /etc/xrdp/startwm.sh /etc/xrdp/startwm.sh1)

  9. Use vim to edit the startwm.sh shell script configuration file:
    sudo vim /etc/xrdp/startwm.sh

  10. The following lines have to be included in the startwm.sh shell script file:
    if [ -r /etc/default/locale ]; then
    . /etc/default/locale
    export LANG LANGUAGE

  11. Make sure one empty line is left at the end of the file.

    startwm.sh configuration file
  12. Save the startwm.sh configuration file after making the changes and quit by pressing Esc and typing: wq. Then, restart the xrdp service:
    sudo service xrdp restart

  13. Identifying the IP address of the Linux machine:
    hostname -I

Either of the above commands will return the machine’s IP address. In our example, the IP address is

In Ubuntu, the firewall is disabled by default. If the firewall is active, you need to open TCP port 3389 to enable remote inbound connections.

sudo ufw allow 3389

You can specify the IP addresses or custom networks that can connect to the remote machine for additional security.

sudo ufw allow from to any port 3389

Note: When accessing a remote machine that is behind a NAT on a local network, you can configure port forwarding to allow connectivity from an external IP address. A VPN connection can be used instead of port forwarding to the remote router or firewall.

How to view a Linux system on a Windows xrdp connection

Open the CMD line in Windows with the Start > Run > CMD combination. Run the following command to open the Remote Desktop client and connect to the remote machine:

mstsc /v:

Choose xorg as the session type and enter your login credentials.

enter your login credentials

After waiting a few minutes, an empty blue screen may be displayed that indicates there is a configuration problem. Use the following steps to get around this issue and fix the xrdp connection.

This problem is caused by changes made in Ubuntu version 18.04 and the xorgxrdp package. These changes have broken the ability to successfully connect using xrdp. Fixing the empty blue screen issue requires that you install the correct version of xorgxrdp-hwe:

sudo apt-get install xorgxrdp-hwe-18.04

You can check the version you are running with this command:

lsb_release -a

Restart the xrdp service:

sudo /etc/init.d/xrdp restart

After the correct package is installed, try to connect to the Ubuntu system again using RDP. Execute the following command in the Windows CMD line:

mstsc /v:

Then, choose xorg in the login window and enter your credentials to establish the connection.

establish the connection

You should now be successfully connected to the Linux machine using the Windows Remote Desktop Protocol. Use the default configuration in the displayed dialog window.

You can modify the resolution by running the mstsc command from the Windows machine. Manually enter the IP address of the Ubuntu system. Select Show Options and choose the desired resolution from the Display tab.

Remote Desktop Connection

Now you can connect to your Ubuntu system from a Windows remote machine using RDP and adjust the screen resolution as needed. You have successfully established the RDP connection which brings us to the end of this demonstration.

Using xrdp on a Linux Mint system

Now, let’s look at how to get xrdp to work on Linux Mint. Many users are interested in using xrdp on Linux Mint. We will use the recent 18.1 release of Linux Mint to demonstrate how to get this accomplished.

Linux Mint xrdp installation and configuration

The following environment is used for our example of installing and testing xrdp with Linux Mint.

  • • A fresh installation of Linux Mint 18.1 is required.
  • • A virtual machine running on Hyper-V Server and VirtualBox is used for the installation.
  • • The Linux Mint computer needs an Internet connection to download the necessary packages. Without an Internet connection, you need to know where to find xrdp for Linux so you can manually download and install it on your machine.

Linux Mint xrdp Installation Process

Step 1 – Install the xrdp package

Log into your Linux mint system and enter the following command in a terminal:

sudo apt-get install xrdp

When the installation is complete, check the xrdp version installed with the xrdp -v command.

Step 2 – Install TigerVnc Server package

A specific VNC Server package is necessary when connecting to the Cinnamon interface in Linux Mint. You need the TigerVNC Server software which is not in the Ubuntu repository.

Download the package and open a Terminal console.

Navigate to the Download folder or wherever you have saved the VNC package. Using the Terminal console, enter the following command to install the package:

sudo dpkg -i tigervncserver_1.7.0-lubuntu1_amd64.deb

If you see error messages or warnings, ignore them for now.

The following command will ensure that all the dependencies are installed:

sudo apt-get install -f

Configure keyboard settings for the xrdp session

Important: This activity needs to be done from the local Ubuntu machine not using the xrdp connection.

The xrdp login screen defaults to an en-us keyboard configuration. This layout will also be used by the remote session. You may be using a different keyboard layout and want to replicate it when connecting through xrdp. Copy and paste the following text to attempt to automatically identify your current keyboard configuration.

# Set keyboard layout in xrdp sessions
cd /etc/xrdp
test=$(setxkbmap -query | awk -F":" '/layout/ {print $2}')
echo "your current keyboard layout is.." $test
setxkbmap -layout $test
sudo cp /etc/xrdp/km-0409.ini /etc/xrdp/km-0409.ini.bak
sudo xrdp-genkeymap km-0409.ini

Now you are finished with the configuration.

Perform the remote Connection.

You should now be able to establish a remote desktop session to the Linux Mint system. You may receive an error message the first time you login. Try again, and you should see the Cinnamon Desktop environment and you can begin working on the Linux Mint computer.

The Cinnamon desktop you are presented with is the software rendered version and not the full interface, as seen in the screenshot above.

What are the pros and cons of xrdp and VNC in Linux?

There are several differences in xrdp and Virtual Network Computing (VNC) that may make one more appropriate for your usage scenario. The main differences are:

  • ✔ A VNC can be made more secure than an xrdp connection.
  • ✔ An xrdp implementation is more cost-effective than using a VNC.
  • ✔ VNC connects directly to the remote computer whereas RDP connects to a shared server.
  • ✔ A VNC may offer more device compatibility than xrdp.
  • ✔ Xrdp is often faster than using a VNC.

Using a third-party solution like Remmina enables you to choose the protocol used for your remote connections. Remmina supports RDP, VNC, and various other protocols, making it a flexible solution for remote desktop access.