fix(chv-guest): 首启缺 key 时才生成 host key(B-23)
Minimal 底座 cloud.cfg 不含 ssh 模块,build.sh 又写 ssh_genkeytypes: [] 彻底关掉首启生成:客机无 host key、 sshd -t 失败、ssh.service 连败 5 次,SSH 全程不通(真机 冒烟 131s 未通,console 已到 login、ping 通、tap 正常)。 修正:99-chv-hostkey.cfg 改写首启 bootcmd,只在缺 ed25519 key 时 ssh-keygen -A;ssh_deletekeys: false 保留, 绝不重生成已预置的 per-VM key(bootcmd 跑在 seed write_files 之前,预置 key 随后覆盖生成值)。README §5 同步修正;新增 BuildScriptTest 回归断言。
This commit is contained in:
1 parent
dcb0824f78
commit
cbd5ab7c0b
3 files changed
+33
-7
No files matched your search
@@ -434,6 +434,25 @@ class BuildScriptTest(unittest.TestCase):
|
||||
% self.repo_commit, r.stdout)
|
||||
self.assertFalse(os.path.exists(os.path.join(out_dir, "disk.raw")))
|
||||
|
||||
def test_hostkey_dropin_generates_missing_keys_at_first_boot(self):
|
||||
# B-23:Minimal 底座的 cloud.cfg 不含 ssh 模块,build.sh
|
||||
# 曾写 ssh_genkeytypes: [] 彻底关掉首启 host key 生成,
|
||||
# 客机无 key、sshd -t 失败、ssh.service 连败 5 次,SSH
|
||||
# 全程不通。修正:首启 bootcmd 只在缺 key 时生成,绝不
|
||||
# 重生成已预置的 per-VM key;写盘的命令里 [] 绝不再出现
|
||||
#(注释里提历史可以,功能行里不行)。
|
||||
with open(self.script) as fh:
|
||||
text = fh.read()
|
||||
hostkey_lines = [ln for ln in text.splitlines()
|
||||
if "99-chv-hostkey.cfg" in ln
|
||||
and "printf" in ln]
|
||||
self.assertEqual(len(hostkey_lines), 1)
|
||||
cmd = hostkey_lines[0]
|
||||
self.assertIn("ssh_deletekeys: false", cmd)
|
||||
self.assertIn("[ -f /etc/ssh/ssh_host_ed25519_key ] "
|
||||
"|| ssh-keygen -A", cmd)
|
||||
self.assertNotIn("ssh_genkeytypes", cmd)
|
||||
|
||||
def test_full_mode_without_kvm_fails_fast(self):
|
||||
# 本 VM 容器内无 /dev/kvm,全量模式必须明确失败,
|
||||
# 绝不声称已建成镜像。
|
||||
|
||||
Reference in new issue
Block a user