Wrong keyboard layout in RDP session over Debian GNU/Linux

I’ve started using XRDP so that my girlfriend can connect her Windows netbook to my Debian GNU/Linux box and do her work. It works pretty well, no 3D acceleration, no remote sound, but everything else is fine. I just had to fix the keyboard layout since we use the Spanish one and XRDP insisted that we should use the U.S. one.

I found this post explaining what I need to do. Basically, XRDP needs a keyboard layout map and Debian doesn’t provide one. Fortunately, creating one is easy with the following command:

# xrdp-genkeymap /etc/xrdp/km-040a.ini

The 040a code can be looked up in this page,  it’s the hexadecimal code preceding every layout name. This has to be done in a local session since it just takes the currently active layout in your X session and writes to a file.

If you’re forced to do it through RDP you have to set the right layout before writing it to the file. Try the following command adjusting parameters to your keyboard layout:

# setxkbmap -layout 'es,es' -model pc105

Next, run xrdp-genkeymap.

Done, restart XRDP.