要记住的第一件重要的事情是在所有处理击键的操作(包括正在通过其进行连接的虚拟机或RDP会话以及顶级主机)上禁用键重复。这不能解决最终目标机器,但可以大大改善这种情况。
至于目标机器:
有报告称,使用ssh连接到HP iLO的SSH端口可避免重复出现密钥的问题,但由于主机(online.net)不允许端口22通过其iLO防火墙,所以我无法使用此方法。但是,如果您可以访问iLO的SSH端口(可能为22),那似乎是最简单的方法。
我尝试使用systemd单位设置启动时的键盘重复率和延迟时间:
# 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
(确保/sbin/kbdrate
是您的位置kbdrate
。写信给/etc/systemd/systemd/slower-keyboard-repeat.service
和systemctl daemon-reload && systemctl enable slower-keyboard-repeat.service
)
但是,正如评论中提到的那样,这只是部分成功,因为需要重新启动才能在iLO所连接的新键盘上设置重复率。但是如果您可以重新启动计算机就可以了。
最终,我最终修补了Linux内核,以更改所有键盘上的默认重复率和延迟时间:
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
那为我解决了问题。