XRDP – Performing a Custom Installation on Ubuntu 16.04

In our previous post, we have described how to perform a standard installation of xrdp on Ubuntu 16.04. If you are a regular reader, you will have noticed that there is no changes since the previous release of Ubuntu (15.x). If you follow us, you probably also know that we like to perform a custom installation of xrdp using the latest version of the xrdp package (which is 0.9.0) that available on the Github web site.

In this post, we will check that the current script we have developed to perform the custom installation is still working and provide the desired results.

The Custom Installation Script (version 1.5)

Overview

The xrdp standard installation process under Ubuntu 16.04 is working fine and you will be able to reconnect to existing session out-of-the-box. If you are like us, you might want to check the progress made by the team behind xrdp solution. To get the bleeding edge xrdp version, you will need to get it from the xrdp Github pages and compile it.

Assumptions

Before running this script, be aware of the following assumptions

We have tested the script on Ubuntu 16.04 Alpha 2

We are installing Mate-Desktop as alternative Desktop. If you want to use another, you will have to update the script provided hereafter

We have performed the test on a Virtual Machine running on Hyper-V Server

Pre-requisites

We assume that you have internet connection on the Ubuntu machine. The internet connection is needed to download the latest version xrdp package. If you are not connected to internet, you can still manually download the xrdp package and modify the install-xrdp.sh script accordingly

The script version 1.5

Important Note :

If you copy/paste the script, you might encounter some issues because font formatting might be not maintained during the copy/paste operation. Please ensure that format is accurate before launching the script.

Version 1.5 of the script will try to configure automatically the keyboard layout to be used during xrdp session. This is experimental. You can uncomment the lines about keyboard layout at the end of the script before the restart section. The script will also try to configure the system in order to enable multiple users configuration for xrdp. Do not hesitate to provide feedback on these small adjustements and let us know if this is working for you as well.

Set Execute rights on the script

You will need to copy/past the script into a text file in your home directory and save it as xrdp-install.sh. In order to be able to execute the script, you will need to mark the script as executable as well under you Ubuntu machine. To make the script executable, you will perform the following action.

Right-click on the file, go to properties, then select permissions and tick the box allow executable….

Click on Picture for better resolution

or you can use the command line to perform the same action. Open your Terminal console and issue the following command

chmod +x ~/Downloads/install-xrdp.sh

(if the file is located in your home directory in the Download Directory. Adapt the path accordingly…)

Click on Picture for better resolution

Execute the script

You are ready to proceed with the custom xrdp installation. As mentioned before, we assume that you have internet connection and you will be able to download all the necessary packages needed to perform this configuration.

When you are ready, you can execute the script by issuing the following command in the command prompt.

Click on Picture for better resolution

We assume that you have downloaded or created the file in the your home folder under the Download folders. If this is not the case, browse to the location and execute the script from there.

Wait for completion of the script. The machine will reboot automatically when done.

Test your xRDP Connection

It’s time to check if the script ran properly. The easiest test to perform is to go to your windows machine and perform an rdp connection to the ubuntu machine where you have run the script. You will need to provide your login information and if the xrdp installation completed successfully, you should see the xRDP login screen (see screenshot)

Click on Picture for better resolution

In the login screen, if you are using a keyboard layout different than EN-US, you will need to check that the script has set the proper keyboard layout for the xrdp login dialog box. In the username field, check that your keyboard layout is set correctly. If this is not the case, go to the section below to perform a manual configuration of your xrdp keyboard layout.

Finally, to test that reconnection to the same session works, you will need to open a first session, start an application and disconnect. Try to connect again, and if everything is working as expected, you should see the application you have started in your previous session.

To test that, you can reconnect to the same session, open some applications and then disconnect. You should see that the applications that you have opened are still there up and running.

Manually configure your xRDP keyboard layout

As in the past, the xRDP login screen will use by default an en-us keyboard layout. You remote session will also be using the en-us keyboard layout. The script will try to automatically detect the keyboard layout your are using and try to map this into the xrdp session. If the script fail to set your keyboard layout properly, you can try to perform the following steps :

In my case, I’m using a Belgian French keyboard, so I had to tell xrdp to use the belgian french keyboard as well. To do that, you need to perform the following actions :

Step 1 : You go to the /etc/xrdp directory

Step 2 : you issue the command setxkbmap -layout <%your layout%> to define which keyboard map/layout to use

Click on Picutre for better Resolution

Step 3 : create a copy of the km-0409.ini file into the same directory.

Step 4 : Check that you have a backup of your file by typing the dir or ls command

Minor Issue

After installing the mate-desktop, you might notice that your ubuntu session (on the console not via xrdp) is a little bit different. You might see something like this.

Click on picture for better resolution

No stress ! This can be fixed quite easily. Sometimes after installing mate-desktop environment, the ubuntu theme is changed. You can set it back right-clicking on your desktop and select change desktop background. This will open the appearance applet where you can reset the default Theme (see screenshot below)

Click on picture for better resolution

You can see that at the theme level, no option is selected. Select the default theme for Ubuntu (which is called Ambiance) or any other theme you would like to use.

Click on picture for better resolution

After a few seconds, you should see the familiar look n feel of your Ubuntu desktop

Click on picture for better resolution

Final Notes

In this post, we have performed a custom installation of xrdp using an updated version of our little script. The process didn’t changed compared to Ubuntu 15.x. The same logic still applies. As mentioned, the script has been updated with some minor improvements and reached version 1.5. This version of the script tries to detect the keyboard layout in use and try to set it for the xrdp sessions. The previous script was also configuring the system for a single user connection. This version of the script change this setting and configure the system for multiple users by default now.

Hi,
Thanks again for your great guides. I’m trying to get this working with KDE, so I’ve replaced the mate-session commands with startkde as per your other guide on KDE. When I login, I get stuck at VNC error – problem connecting.

I would need to have a look if the KDE is still working with xrdp. I have seen some reports that indeed the desktop is greyed out starting with (K)UBuntu 15.04
To check what’s happening, you should have a look at different logs files. You should look at the following files

In the meantime, I’m using KDE as default for development, and try to connect from remote windows machine for coding. Would you mind if you can test with Ubuntu 16.04/14.04.2 for Xrdp? I have followed your instruction, but it didn’t work at all with KDE. I will update once I figure it out as well.

Another question is that How to use copy&paste between windows and XRDP session? Currently, I’m using mRemoteNG for RDP client in Windows. I CAN’T use copy&paste feature. Would you tell me what RDP client you are using for copy&paste?

Thanks for the script, I use it on every machine I install.
There is one minor problem.
Using your script on a headless server, the script ran into an error in one of the last lines
test=$(setxkbmap -query | awk -F”:” ‘/layout/ {print $2}’)
result: Cannot open display “default display”
The error is logical, as i do not have any display connected.
xrdp works after that, except the keyboard layout – obviously.
Thanks

Hello Andres,
Thank you for the feedback and the visit…
Did you get the error only on the machine with no monitor or this is a recurring one. If this a recurring one, let me know and i will try to update the script

If the script has not set the keyboard, you can always set it manually

Hi
it happens only using your script without previous local login into the mate-desktop. (ubuntu-mate-cloudtop and ubuntu-mate-desktop)
copying the km-0409.ini does help to get the correct layout, but:
in the rdp desktop i use virtual-manager and this one use some vnc to control the virtual machines and there i got no keystroke within the RDP.
I also tried to rsync the user from a working system, no luck.

Hi
here the results of my investigation.
If someone is interested in using a headless ubuntu server 16.04 using this script to remote control the computer in combination with an installed virt-manager:
If the above mentioned error remains – just copy a correct km-0409.ini and replace in the virt-manager the spice interface with the old vnc protocol. After that typing into the windows of the virt-manager works in the rdp session.
Thanks again for the great script !!!!

Hello Andres,
as soon as we have time, we will have a look at on to install xrdp on ubuntu server (which requires to install more components including keyboard utilities)
thank you for all the feedback we will try to improve the content of our blog with this info

Ok, good to hear but what’s different from your installation compared to a standard fresh installation of ubuntu and adding xrdp package
What have you installed differently than the post describe ? We cannot reproduce your error.

either, you simply install the xrdp package, check that the /etc/xrdp/startwm.sh has the line xfce-session and you will be able to connect via xrdp and you will see you xfce interface

or you can run the script as is and connect to your system via xrdp and have the mate-desktop interface
or you can modify the script, don’t install the mate desktop and update the the line in the script from mate-session to xfce-session

Hi I made a vmware ubuntu vm using xubuntu and let the script install as default changing nothing but when I try to connect ot the ip of the machine with rdp I can’t it has it’s own ip and is bridged so it should be able to and it starts with the default 192.168 so why can’t I connect no static ip maybe?

Hi,
after several tries I still cant get the ‘Xvnc-sesman-…’ in my drop down menu of the xrdp start screen, and thus no connection.
The rest of the script runs fine and w/o any error messages as far as I could see. Only I had to make some adjustments before hand:
a) due to proxy issues I downloaded the xrdp-master.zip manually (which btw contains the old version 0.6.2!) and let the script run accordingly with out the download, starting with unzip…
b) second thing I tried: using manually downloaded and extracted version 0.9.1 from https://github.com/neutrinolabs/xrdp/releases/tag/v0.9.1
same procedure (out commented download and unzip, rest remained as it was)
in both cases not the right drop down option…
What can I do?
PS: before I also had the standard installation of xrpd for ubuntu 16.04 running but it kept closing the windows of the applications directly after starting.

I think the best option in your case would be (if possible) to have the latest version of Ubuntu installed (Ubuntu 16.10)
Ubuntu 16.10 ships by default with xrdp package 0.9.x. You simply need to perform a apt-get install xrdp and you should have the software installed and working out of the box

The script was tested up to xrdp 0.9.0, we will need to check if xrdp version 0.9.1 brings news stuff that might break the installation script.
If you really want to have it running on Ubuntu 16.04, (and if you didn’t do it yet), try the install on a new machine ( using virtual machine so you can perform snapshots) and ensure that the script is running as expected and that xrdp is working. Then, you could try to compare working and non working system and try to see what could be the problem

Hi, thanks for the great article; unfortunately it doesn’t seem to be working for me.

I just reinstalled Ubuntu 16.04 the other night, so brand new installation – the script ran fine without any errors, but when I went back to my Mac (running Microsoft’s official rdp client), it comes back almost immediately with no connection.

I made sure my router has port 3389 open to my Linux box, but then I checked netstat -an | grep “3389”, and nothing comes back – maybe the service isn’t running? How can I check on the Linux side?