The first critical thing to remember is to disable key repeat on everything processing your keystrokes, including on the virtual machine or RDP session you're connecting through, as well as the top-level host machine. This does not fix the final target machine but it does a lot to improve the situation.
As for the target machine:
There are reports that using ssh to connect to HP iLO's SSH port avoids key repeat issues, but I could not use this method because my host (online.net) did not let port 22 through their iLO firewall. But if you have access to iLO's SSH port (likely 22), that seems like the easiest approach.
I tried using a systemd unit to set the keyboard repeat rate and delay time on boot:
# Note that kbdrate only affects existing keyboards, and HP iLO attaches a new
# USB keyboard when you connect, so you may have to reboot (with the iLO console
# attached) to get the keyboard delay and repeat rate to take effect.
[Unit]
Description=Set longer delay time for key repeat
[Service]
Type=oneshot
RemainAfterExit=yes
StandardInput=tty
StandardOutput=tty
ExecStart=/sbin/kbdrate -d 1000 -r 2
[Install]
WantedBy=multi-user.target
WantedBy=rescue.target
(Make sure /sbin/kbdrate
is where you have kbdrate
. Write to /etc/systemd/systemd/slower-keyboard-repeat.service
and systemctl daemon-reload && systemctl enable slower-keyboard-repeat.service
)
but as mentioned in the comment, this was only a partial success because it required a reboot to set the repeat rate on the new keyboard that iLO attaches. But it is good enough if you are OK with rebooting the machine.
Ultimately, I ended up patching the Linux kernel to change the default repeat rate and delay time on all keyboards:
From 78c32f539b89bf385985bea47a7058a540d31da0 Mon Sep 17 00:00:00 2001
From: Ivan Kozik <ivan@ludios.org>
Date: Thu, 30 Mar 2017 13:31:17 +0000
Subject: [PATCH] Increase the default keyboard repeat delay from 250ms to
1000ms and repeat rate from 1000/33 Hz to 1000/500 Hz to avoid unintentional
repeated keystrokes when using remote consoles such as HP iLO over
high-latency links. These consoles (HP iLO included) often transmit key
states (up/down) instead of keystrokes, making it impossible to even enter a
password and log in.
Fixing this in the kernel avoids problems with kbdrate where the parameters
passed to kbdrate don't apply to the new keyboards attached by HP iLO.
---
drivers/input/input.c | 2 +-
drivers/input/keyboard/atkbd.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 880605959aa6..a195af2d062a 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -2126,7 +2126,7 @@ int input_register_device(struct input_dev *dev)
* is handled by the driver itself and we don't do it in input.c.
*/
if (!dev->rep[REP_DELAY] && !dev->rep[REP_PERIOD])
- input_enable_softrepeat(dev, 250, 33);
+ input_enable_softrepeat(dev, 1000, 500);
if (!dev->getkeycode)
dev->getkeycode = input_default_getkeycode;
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index ec876b5b1382..9dd04c2215b3 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1096,8 +1096,8 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd)
BIT_MASK(LED_MUTE) | BIT_MASK(LED_MISC);
if (!atkbd->softrepeat) {
- input_dev->rep[REP_DELAY] = 250;
- input_dev->rep[REP_PERIOD] = 33;
+ input_dev->rep[REP_DELAY] = 1000;
+ input_dev->rep[REP_PERIOD] = 500;
}
input_dev->mscbit[0] = atkbd->softraw ? BIT_MASK(MSC_SCAN) :
--
2.11.0
and that solved the problem for me.