frame

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Register

How to install XRDP on Ubuntu/Debian

MichailMichail Moderator
edited October 7 in Linux Applications

Introduction

This guide will help you set up XRDP on a server running Ubuntu or Debian so that you can comfortably connect to it from any Windows machine. This approach is convenient when there is a need to connect from a Windows computer to a Linux machine with a graphical interface (not SSH).

This guide is suitable for Ubuntu (starting from 20.04 version) and Debian (starting from 11 version).

Please note. In this tutorial, we use vi as the text editor. However, on Debian, the default vi editor is a minimal version that lacks some advanced features, making it difficult to handle tasks like pasting text from external sources. For a more user-friendly experience, consider using nano.

Installation Guide

1. Update the system

First of all, make sure to update your system:

apt update
apt upgrade

2. Install XRDP

Once you have ensured that your system is up to date, you can run this command to install XRDP:

apt install xrdp

Some distributions will allow you to select a keyboard layout. Select the layout you want (in this guide, we chose English (US)) and press Enter to continue.

3. Install a Desktop Environment

Next we need to install the desktop environment. For XRDP, we recommend you install Xfce. Run this command to install Xfce:

apt install xfce4 xfce4-goodies

On some distributions you will need to select a display manager at this step. Since we are installing Xfce, we recommend you select lightdm:

4. Configure xrdp settings

After installing Xfce, you need to edit the XRDP startup file:

echo "xfce4-session" > ~/.xsession

Now you update xrdp configuration file. Open the file:

vi /etc/xrdp/startwm.sh

Find the following line:

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

Comment out this line with # at the beginning:

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

After that, add this line to the end of the file:

. /etc/X11/Xsession

5. Restart xrdp

For the changes to take effect, restart the xrdp service:

systemctl restart xrdp

6. Allow RDP port

To access your server via xrdp, you need to enable the default RDP port - 3389. You can do this via iptables or ufw (depending on what you use).

UFW:

If you want to enable port 3389 via UFW, first make sure it is installed and enabled. If UFW is not installed, run this command:

apt install ufw

Next, enable ufw:

ufw enable

Now you can open port 3389:

ufw allow 3389/tcp

If you just installed UFW, don't forget to allow port 22 as well (otherwise you'll lose your SSH connection):

ufw allow 22

IPtables:

If IPtables is not already installed on your server, run the following command:

apt install iptables

To enable port 3389 via IPtables, run the following command:

iptables -A INPUT -p tcp --dport 3389 -j ACCEPT

Then run this command to save the changes:

netfilter-persistent save

If netfilter-persistent is not installed, you can alternatively use this command to save the changes:

iptables-save | tee /etc/iptables/rules.v4

7. Test XRDP

Windows computer:

On Windows computers, we recommend you to use the Remote Desktop application. Open it and enter credentials for connection:

Computer: Your_server_IP
Username: root

Click "Connect" to continue and you will see login page, where you need to enter a password of your root user:

Please note, that you can't copy/paste in this window. So you need to type password manually. However, you can save your password for future - click "Allow me to save credentials".

Linux:

You can connect via RDP from a Linux computer by using the rdesktop application.

To install it on Ubuntu/Debian, run these commands:

apt-get update

apt-get install rdesktop

To install it on CentOS/AlmaLinux/Rocky Linux 9, run these commands:

yum update

yum install rdesktop

To connect to the server, run the following command:

rdesktop -u root -p PASSWORD -g 1024x768 YOUR_SERVER_IP

Change the "PASSWORD" and "YOUR_SERVER_IP" to your actual password and server's IP.

You can change the resolution by updating the "-g 1024x768" parameter.

At this point, you should be able to connect to the server via XRDP. However, some distributions may have issues. If you get an error or have other issues, be sure to check the next section.

Please note. Loading the desktop environment may take longer on some distributions. This is normal behavior, so you just have to wait.

Possible problems after installation and ways to solve them

1. Error "Unable to Contact Settings Server"

After installation and attempting to access the server, you may encounter the following error message:

This error indicates that the DBus system, which is responsible for inter-process communication is missing certain components. To solve the issue, you need to install dbus-x11 package.

Run this command (via SSH):

apt install dbus-x11
Then recheck RDP connection again. It should work now.

2. The terminal is not working

After installing a server that you accessed via RDP, you may find that the default terminal from the main panel does not work. You will get the error "Failed to execute default Terminal Emulator" followed by "Input/output error" :

However, Xfce Terminal (you can find it with Application Finder) will work. The problem is related to the system being unable to find or launch the terminal specified as the default. In this case, you need to run this command via SSH:

update-alternatives --config x-terminal-emulator

You'll see a list of available terminal emulators. Look for Xfce Terminal (it may be listed as xfce4-terminal) and select it by typing its corresponding number:

In our case the corresponding number is 2. The list may vary depending on the OS.

After that, try opening the terminal from the main panel again. Xfce Terminal should now open by default.

Conclusion

Installing XRDP on Ubuntu and Debian allows you to remotely access the system using the Remote Desktop Protocol (RDP), providing a convenient graphical interface for managing your machine. By following the steps in this guide, you can successfully install XRDP, configure the desktop environment (such as Xfce), and troubleshoot common issues.

With XRDP set up, you can easily manage your Linux server or desktop remotely, improving both accessibility and convenience.

Comments

  • bhioojbhiooj Member

    Thanks for the detailed guide, Michail! Installing XRDP can really simplify remote access to a Linux machine from Windows. It’s great to have a straightforward method to set up a graphical interface. For additional resources and insights on Linux applications, you might want to explore newtoki.blog/.

Sign In or Register to comment.

Time4VPS

Learn how to install a web and database server, email, FTP client or other applications. Discover and share information on server security or optimization recommendations.
Feel free to join our constantly expanding community, participate in discussions, strengthen your knowledge on Linux and Windows server management!
© 2013 - 2024 Time4VPS. All rights reserved.

Get In Touch