For XRDP connections, I finally solved the problem by editing the keymap file. In my case this is km-0409.ini but it should work for all files. I am using Ubuntu Mate and access it with Windows Remote Desktop Connection.
Before you start, please create a backup of your keymap file as this is something that is not thoroughly tested and may interfere with other things.
Step 1: In case you use another keymap file, run xmodmap -pk > Layout.txt from a terminal. In that file look for the key numbers associated with the KP_ keys. In my default file these are the key numbers between 79 and 91.
Step 2: Go to /etc/xrdp and sudo edit the keymap file you are using (e.g. km-0409.ini) and replace the values of the keys you identified in the previous step with the correct unicode values (http://unicode-table.com/en/#control-character). I only changed the values under [noshift].
For me the values are as follows:
Key number | New value | Character displayed
79 | 55:55 | 7
80 | 56:56 | 8
81 | 57:57 | 9
82 | 45:45 | -
83 | 52:52 | 4
84 | 53:53 | 5
85 | 54:54 | 6
86 | 43:43 | +
87 | 49:49 | 1
88 | 50:50 | 2
89 | 51:51 | 3
90 | 48:48 | 0
91 | 46:46 | .
Step 3: Save the file and reboot the system.
There is one small issue that I could not solve yet and that is the fact that the numbers now only work when Num Lock is off. In the remote session this is no problem as it seems that all other programs still show the correct input from the keypad even when Num Lock is off. When going back to the host system this is of course still a problem. Maybe this can be solved by also changing the values under the [shift], [alt-gr], [capslock], … items but I haven’t had time to check that yet.
Edit: Confirmed it works with Num Lock on when you change the values under all items in the ini file [shift], [noshift], [capslock], … Again, this might break other stuff but for now it works.
Edit 2 This will obviously break the non-Num Lock input so it becomes impossible to use e.g. the Home or PgUp key from the numeric keypad. This can most likely be solved by only changing values before or after the ‘:’ and in some specific items in the ini file. As I don’t use these keys on the numeric keypad this is no issue for me.