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
+8
-3
@@ -51,8 +51,13 @@
|
||||
# 客机必须装 cloud-init 且支持 NoCloud seed,首启先应用
|
||||
# seed 再启动 sshd,且不得无条件重新生成 host key,否则
|
||||
# 执行器的 per-VM 预置钉死即失效。本脚本在镜像里写
|
||||
# /etc/cloud/cloud.cfg.d/99-chv-hostkey.cfg(ssh_deletekeys:
|
||||
# false、ssh_genkeytypes: []),把“不重生成”钉进镜像。
|
||||
# /etc/cloud/cloud.cfg.d/99-chv-hostkey.cfg:ssh_deletekeys:
|
||||
# false(绝不删已有 key)+ 首启 bootcmd 只在缺 key 时
|
||||
# ssh-keygen -A(bootcmd 跑在 seed write_files 之前,预置
|
||||
# key 随后覆盖生成值,最终仍是预置 key)。
|
||||
# B-23:曾写 ssh_genkeytypes: [],彻底关掉首启生成;Minimal
|
||||
# 底座 cloud.cfg 又不含 ssh 模块,客机无 host key、sshd -t
|
||||
# 失败、ssh.service 连败,SSH 全程不通——[] 已删,绝不再写。
|
||||
#
|
||||
# 注:Minimal 底座虚拟盘 3.5G(根分区 2.4G,实测 1.9G 空闲),
|
||||
# qemu-img convert 出的 disk.raw 表观 3.5G、实际占用约 0.6G
|
||||
@@ -243,7 +248,7 @@ VC_ARGS=(-a "$OUT/disk.raw"
|
||||
--run-command 'git config --system user.name chv && git config --system user.email chv@localhost && git config --system credential.helper store && git config --system init.defaultBranch main'
|
||||
--run-command "$GT_INSTALL_CMD"
|
||||
--run-command '/usr/local/bin/gt version > /app/guest-versions-gt.txt'
|
||||
--run-command 'printf "ssh_deletekeys: false\nssh_genkeytypes: []\n" > /etc/cloud/cloud.cfg.d/99-chv-hostkey.cfg; systemctl enable ssh || true'
|
||||
--run-command 'printf "ssh_deletekeys: false\nbootcmd:\n - \"[ -f /etc/ssh/ssh_host_ed25519_key ] || ssh-keygen -A\"\n" > /etc/cloud/cloud.cfg.d/99-chv-hostkey.cfg; systemctl enable ssh || true'
|
||||
--run-command 'printf "PasswordAuthentication no\nPermitRootLogin prohibit-password\nChallengeResponseAuthentication no\nKbdInteractiveAuthentication no\nPubkeyAuthentication yes\n" > /etc/ssh/sshd_config.d/99-chv.conf && mkdir -p /run/sshd && ssh-keygen -A && sshd -t && grep -q "^PasswordAuthentication no" /etc/ssh/sshd_config.d/99-chv.conf && grep -q "^PermitRootLogin prohibit-password" /etc/ssh/sshd_config.d/99-chv.conf && rm -f /etc/ssh/ssh_host_* && test -z "$(ls /etc/ssh/ssh_host_* 2>/dev/null)"'
|
||||
--run-command 'dpkg-query -W -f "\${Package} \${Version}\n" > /app/guest-versions-dpkg.txt; pip3 freeze > /app/guest-versions-pip.txt || true')
|
||||
if [ "${PLAYWRIGHT:-1}" = "1" ]; then
|
||||
|
||||
Reference in new issue
Block a user