xRDP – Strange issue with Keyboard layout and how to fix it (Really Rare)

Hello World, 

Today, we want to quickly tackle another strange issue that you might have already encountered (even this behavior is really rare).  It happens to us recently (not the first time) and we really wanted to get a permanent (we hope) fix for this keyboard issue…. 

So, let’s go quickly through the problem and let’s try to explain the fix…. 

Problem Description 

This “specific” keyboard problem will affect mainly non-english keyboard users.  If you are using an English keyboard layout, you should never noticed the problem.  However, if you are using a non-english keyboard, it might happen that when reconnecting to your xRDP session, you have reached the lock screen of your Ubuntu System (the gdm login page) and you digit your password and you discover that you receive a message… Authentication failed.  

Click on Picture for Better Resolution

After a quick investigation,  you will notice that the keyboard layout to be used in the lock screen (through xrdp session) is English while your system is configured for non-English keyboard layout.

Let’s be even more specific.   I have installed Ubuntu 20.04 on my lab and installed and configured the xRDP Package. Since we are currently working in Belgium, our keyboard layout is set to Belgian layout.  99% of the time when accessing the Gnome Lock screen via xRDP software, my keyboard layout is set correctly (Belgian Keyboard).  1 % of the time, it might happen that the keyboard layout within the remote session is not set to the localized one to be used but revert back to English.  

When realizing that the keyboard layout is set to English, we can digit our password correctly and we have access to our remote session.   This is where the strange things are visible.  Within the remote session, if we check the keyboard layout through the command line,  we can see that the keyboard layout is set to  en-US.  However, if we look at the GUI interface for the keyboard layout, we can clearly see that the keyboard layout is set to Belgian.  If you type in the Terminal, you will see that the English keyboard layout is actually used…. 

Click on Picture for Better Resolution

We have been checking the logs  (in /var/log/xrdp.log) to try to find some hints for this strange behavior.  We can see some errors related to the local keymap file.  Write down this information as this might be useful at a later stage.  On the other hands, you might notice that this warning message is also displayed when everything is working accordingly which means that we can safely ignore it as well in such situation 

Click on Picture for Better Resolution

Possible Fix 

To fix this issue, we will need to edit the file 

/etc/xrdp/xrdp_keyboard.ini

If we move to the [default_layouts_map] section,  we can list all the defined layouts used by the xRDP software….

Click on Picture for Better Resolution

In our specific scenario, we needed to add the Belgian layout map information…So, under [default_layouts_map] section, we have to check if the correct layouts map is defined accordingly (for the keyboard layout we are using). Under the section (in our specific scenario for Belgian Keyboard), you should see a line which looks like this under that section… (see screenshot)

  rdp_layout_be=be

Click on Picture for Better Resolution

Note : It’s possible that the entry is already available in the list.  If this is the case, do nothing….

Now, we have to move to the following section  [default_rdp_layouts], we have to check if the missing keyboard layout specified in the /var/xrdp/xrdp.log file (see screenshot above) is present under this rdp_layouts section.  In our case, this specific keyboard layout was not specified.   The log file (in our specific scenario) is indicating that the following rdp layout is not present in the xrdp_keyboard.ini file 

0x000080c

Using this information, we have added under the  [default_rdp_layouts] the following information (for our specific scenario) 

rdp_layout_be=0x000080c 

The xrdp_keyboard.ini file looks like this after our modification 

Click on Picture for Better Resolution

Finally, when all the changes have been done and saved into the file, disconnect the session of the problematic user and reconnect.  The keyboard layout in the lock screen (gdm login manager) will be set to the correct keyboard you have initially defined.  When checking again, when remotely connected to your Ubuntu system, you will notice that the command line output and the gui output matches and the problem is gone…. 

Click on Picture for Better Resolution

 

Final Notes

This is it for this post !  

This post is covering a really specific and rare issue we have encountered while working with xRDP software solution.   While the non-English keyboard layout settings is defined correctly, it might happens that when reconnecting to your session, you will notice that the keyboard layout is reverted back to English layout with no reasons.   The keyboard layout change is not happening in the xRDP Login screen but after.  When connected to your system remotely, you will probably reach your gdm lock screen and this is where the keyboard layout get changed. 

We do not know exactly why this is happening.  However, we know how to fix it.  You will first need to check which keyboard layout is missing on your system by checking the /var/log/xrdp.log.  When you have found the information, simply edit (in read-write mode) the file /etc/xrdp/xrdp_keyboard.ini and add under the [default_rdp_layouts]  the missing layout… And this should fix your issue…. 

Hope this help 

Till Next time

 

Leave a Reply