fix(chv): known_hosts 22 端口写裸 host 行,修 provisioned 钉死失效
OpenSSH 默认端口只查裸 host 名、非默认端口只查 '[host]:port':known_hosts_line 对 22 端口也写 '[192.168.10.10]:22',ssh 永远匹配不上,报 Host key verification failed、wake fail-closed 关 VM。keyscan TOFU 输出裸行,lite9 没暴露。非 22 端口仍用括号形式。
This commit is contained in:
1 parent
4f3a176771
commit
ba5df980bf
2 files changed
+25
-4
No files matched your search
@@ -318,6 +318,17 @@ class HostKeyProvisionTest(ChvGapCase):
|
||||
self.assertFalse(os.path.exists(r["paths"]["private"]))
|
||||
self.assertTrue(os.path.exists(r["known_hosts"]))
|
||||
|
||||
def test_known_hosts_line_port_22_is_bare(self):
|
||||
# 22 端口写裸 host 行:OpenSSH 默认端口只查裸名,
|
||||
# '[host]:22' 永远匹配不上(2026-11-07 WSL 真机)。
|
||||
self.assertEqual(
|
||||
known_hosts_line(22, "ssh-ed25519 AAAAx comment",
|
||||
host="192.168.10.10"),
|
||||
"192.168.10.10 ssh-ed25519 AAAAx")
|
||||
self.assertEqual(
|
||||
known_hosts_line(2222, "ssh-ed25519 AAAAx comment"),
|
||||
"[127.0.0.1]:2222 ssh-ed25519 AAAAx")
|
||||
|
||||
def test_known_hosts_line_rejects_bad_key(self):
|
||||
with self.assertRaises(ValueError):
|
||||
known_hosts_line(2222, "not-a-key")
|
||||
|
||||
Reference in new issue
Block a user