ubuntu 22.04 server install xrdp xface4

thelinuxinfo.com

 

Installing Desktop Environment

 Ubuntu Server does not have any installed Desktop Environment by default. So you will need to add a desktop environment to the system. We will install a lightweight desktop environment that will act as a backend for Xrdp here we will install Xfce, It is one of the fast, most stable, and lightweight desktop environments, which makes it ideal for usage on a remote server.

Run the following commands to install Xfce on the server:

$ sudo apt update
$ sudo apt install xfce4 xfce4-goodies xorg dbus-x11 x11-xserver-utils

Installing Xrdp

Execute the following commands to install Xrdp:

$ sudo apt install xrdp
Xrdp install output

To check the status execute the following command:

$ sudo systemctl status xrdp

The output will look something like this:

Xrdp status

To add a user execute the following command:

Note: Please keep the password and it will be required to log in to the remote desktop.

$ sudo adduser linuxinfo

Configuring Xrdp

During installation xrdp user has been added to the system and the xrdp session uses a certificate key file “/etc/ssl/private/ssl-cert-snakeoil.key”.

Execute the following command to add the xrdp user to the “ssl-cert” group with the following command:

$ sudo usermod -a -G ssl-cert xrdp 

Please follow the below command to resolve the black screen issue in the background screen. If you are not facing this issue you can ignore these steps.

$ sudo vim /etc/xrdp/startwm.sh 

Add below lines as shown in the picture.

Xrdp configuration

unset DBUS_SESSION_BUS_ADDRESS

unset XDG_RUNTIME_DIR

Save and restart the service.

Execute the following command to restart the service.

$ sudo systemctl restart xrdp

Configuring Firewall for Xrdp

By default, Xrdp listens on port 3389 and needs to add a rule that will enable traffic on the Xrdp port.

To allow access to the Xrdp server from a specific IP address or IP range, 

Execute the following command if your IP range is x.x.x.x/24

$ sudo ufw allow from x.x.x.x/24 to any port 3389

If you are using AWS cloud, you must add an inbound rule for the same.

If you want to allow access from anywhere (which is not a good practice for security reasons) run:

$ sudo ufw allow 3389

Connecting to the Xrdp Server

Now Xrdp has been set up and time to connect to the server. For the windows system open “Remote Desktop Connection”. Below window will appear, put the IP of Xrdp server and click on connect.

Remote desktop connection for Xrdp

 

Next Login details will ask.

Xrdp(Remote desktop connection) login page with user name and password

Click On OK and below window will appear.

Remote desktop window via Xrdp