When I open an xrdp session from a Windows 7 machine to my Ubuntu machine, US keyboard layout is utilized. However, my default keyboard layout is different on Ubuntu machine and I want to use it during xrdp sessions. How can I fix this?

  • Which keyboard layout would you like to set? Check askubuntu.com/a/593944/385763
    – Yasel
    Mar 7, 2015 at 19:27
  • I am still working on that, too. This should be a good starting point ➝ c-nergy.be/blog/?p=3858
    – Frank N
    Feb 14, 2016 at 17:15
  • What I'm noticed is that even now on Windows 10 with pre-configured Ubuntu 18 image from Hyper-V keyboard layout switching sometimes stops working on Hyper-V VM with Ubuntu from time to time, for example when it resumes after Hyper-V host reboot... In that case issue does not goes away until I reboot VM.
    – Mike
    Oct 23, 2019 at 7:16

7 Answers 7


I'd like to contribute here, since there seems to be little instructions.

Find the language / keyboard input you need from here

So for example fr-be French (Belgium) is 080C.

Then run these commands to generate the keyboard mapping for your chosen input.

xrdp-genkeymap km-080C.ini

To copy it in the xrdp folder

sudo mv km-080C.ini /etc/xrdp

Remember that you must change the permissions of the file, so that it can be used

sudo chown root:root /etc/xrdp/km-080C.ini

Restart the service and it should work

sudo service xrdp restart
  • 1
    Thankyou Enrico, this issue had been driving me crazy for hours - the extra explanation and info is great
    – Oly Dungey
    Apr 25, 2018 at 16:00
  • I got a crash when restarting the service, probably because now services are managed using systemd. In this case, what worked for me is sudo systemctl restart xrdp Jul 16, 2019 at 12:11
  • IMPORTANT: You have to generate the keymap from your normal Ubuntu session, not from under xrdp.
    – sola
    Feb 23, 2022 at 9:07

for me it was enough to run next command, in order to set the right keyboard map in X

setxkbmap be

where you must replace the "be" with your land code. You can see the current value with

setxkbmap -query
  • 1
    This works, but for the life of me I couldn't figure out how to have this run automatically upon login (my context is ubuntu vm running on a windows 10 host using hyper v with rdp connection) Aug 19, 2022 at 5:45
  • 1
    I added setxkbmap be line to /etc/xrdp/reconnectwm.sh as on reconnect, my session would return to the default us keyboard layout. My sincere thanks from a fellow Belgian. Oct 13, 2022 at 7:48

Unfortunately none of the above answers completely solved my problem.

After looking into directory sudo ls /etc/xrdp/ I found out that .ini files had more 0 prefixes, so instead I had to do the following, to make it work.

sudo xrdp-genkeymap /etc/xrdp/km-00000424.ini (Slovenian layout)

and then additionally edit file sudo vi /etc/xrdp/xrdp-keyboard.ini and add the following lines after each section:


; <rdp layout name> = <X11 keyboard layout value>


I hope that helps someone.

  • Indeed, xrdp uses the mapping between default_rdp_layouts and default_layouts_map to know which keyboard layout to use for the X session. If the keyboard code sent by the rdp client is not listed, then it defaults to a "us" layout. Thanks for the answer, it helped fixing my issue with keyboard code 0xa000040c (fr) sent by Windows!
    – Tey'
    Oct 7, 2022 at 12:35

if you have installed xrdp, you should have te xrdp-genkeymap installed on your system. the utility will be located under /etc/xrdp folder

To change keyboard layout, you need indeed to issue the xrdp-genkeymap command. The command has to be run locally on the ubuntu machine and not from the xrdp session.
issue the following command to use us layout keyboard during your xrdp session sudo xrdp-genkeymap /etc/xrdp/km-0409.ini

If you need other language layout, you have to find the correct km-xxx.ini file

Hope this help Till next time see ya


Unfortunately, manipulation with ini files did not work for me. Maximum what I could get is the additional layouts, which are also English. So I ended up with 3 weird named English layouts. What helped is adding this to the beginning of the /etc/xrdp/startwm.sh and /etc/xrdp/reconnectwm.sh right after the 1st line, example:

( sleep 3; setxkbmap -model pc105 -layout us,ru -option grp:alt_shift_toggle )&

Or if you want to set XRDP keyboard layout from system-wide settings file /etc/default/keyboard, which is probably what you want, than put this instead:

. /etc/default/keyboard
( sleep 3; setxkbmap ${XKBMODEL:+-model "$XKBMODEL"} ${XKBLAYOUT:+-layout "$XKBLAYOUT"} ${XKBVARIANT:+-variant "$XKBVARIANT"} ${XKBOPTIONS:+-option "$XKBOPTIONS"} )&

BTW setting up the system-wide keyboard settings file /etc/default/keyboard itself may be done in the following ways:

  • Editing it by hand
  • With the configuration utility: dpkg-reconfigure keyboard-configuration
  • With the command line utility: localectl set-x11-keymap us,ru pc105 , grp:alt_shift_toggle

Try to locally run this code not from xrdp session :

xrdp-genkeymap /etc/xrdp/km-0409.ini

Restart xrdp and try .

  • There is no xrdp-genkeymap command on my system. Jan 30, 2014 at 7:57

I was in the same situation as k3br, the answer by Enrico didn't work for me, and the solution for me was similar to k3br's answer. However in my case the name of the km-xxxxxxxx.ini file that I got from looking up my keyboard from this link from Enrico's answer didn't match the file that xrdp was trying to open upon login.

I used the idea described here to figure out which keyboard file xrdp was trying to open upon login by running the following

sudo cat /var/log/xrdp.log | grep key

which gave this output:

[20220818-16:43:48] [INFO ] Cannot find keymap file /etc/xrdp/km-00001009.ini
[20220818-16:43:48] [INFO ] Loading keymap file /etc/xrdp/km-00000409.ini

So in my case xrdp was trying to open km-00001009.ini, couldn't find it so defaulted to km-00000409.ini, which is the US keyboard. I have no idea why xrdp was looking to the km-00001009.ini, since that corresponds to the english (canada) keyboard according to the link above and I am using the french (canada) keyboard. So what I did is I generated the km-00001009.ini file from a non-xrdp session on the ubuntu machine where the keyboard I want was active, using

xrdp-genkeymap km-00001009.ini

and copied it to /etc/xrdp/, as in Enrico's answer above.

Finally, I had to add the following lines in the /etc/xrdp/xrdp_keyboard.ini file, as xrdp apparently checks that there is a key corresponding to the km file inside that xrdp_keyboard.ini file and bails otherwise:


I actually don't know how much the language letters following rdp_layout_ (fr_ca, for french canada in my case) matters, I suspect it doesn't. I also don't know if the "ca" in the rdp_layout_fr_ca=ca matters. ca is the letters for the french canada keyboard so that's why I put it, but I didn't try with other letters to see if it would work regardless.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .