fix(ssh): ensure SSH host keys are generated on startup via systemd drop-in and bootstrap script (#27)
### Summary of Changes - Added systemd drop-in override `/etc/systemd/system/ssh.service.d/10-generate-host-keys.conf` with `ExecStartPre=-/usr/bin/ssh-keygen -A` so `ssh.service` auto-generates host keys if missing on startup. - Added `ssh-keygen -A` to `03-cleanup.sh` and `bootstrap-cluster.sh` in `user-data.template.yaml`.
This commit is contained in:
1 parent
502ef94bb2
commit
ac681d77da
3 files changed
+12
-4
No files matched your search
@@ -37,6 +37,13 @@ update-grub
|
||||
# Enable serial console getty
|
||||
systemctl enable serial-getty@ttyS0.service || true
|
||||
|
||||
# Ensure SSH server auto-generates host keys if missing before starting
|
||||
mkdir -p /etc/systemd/system/ssh.service.d
|
||||
cat << 'EOF' > /etc/systemd/system/ssh.service.d/10-generate-host-keys.conf
|
||||
[Service]
|
||||
ExecStartPre=-/usr/bin/ssh-keygen -A
|
||||
EOF
|
||||
|
||||
# Configure cloud-init to use NoCloud and ConfigDrive datasources
|
||||
cat << 'EOF' > /etc/cloud/cloud.cfg.d/99-cloud-init.cfg
|
||||
datasource_list: [ NoCloud, ConfigDrive, None ]
|
||||
|
||||
@@ -14,8 +14,8 @@ truncate -s 0 /etc/machine-id
|
||||
rm -f /var/lib/dbus/machine-id
|
||||
ln -sf /etc/machine-id /var/lib/dbus/machine-id
|
||||
|
||||
# Remove generated SSH host keys (re-created by cloud-init on first boot)
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
# Ensure SSH host keys are generated and valid
|
||||
ssh-keygen -A
|
||||
|
||||
# Clean cloud-init logs, state, and reset temporary build DNS
|
||||
rm -f /etc/resolv.conf
|
||||
|
||||
Reference in new issue
Block a user