Fix SSH host keys generation for live CD and installed system

- Add generate-ssh-keys.hook.chroot for live CD build
- Generate RSA, ECDSA, and Ed25519 SSH host keys during build
- Add SSH key generation to auto-installer for installed system
- Remove existing keys before generating new ones
- Fix 'no hostkeys available' SSH server error
- SSH server can now start properly on both live CD and installed system
parent 89916b99
#!/bin/bash
# Generate SSH host keys for live CD
# This ensures SSH server can start properly
set -e
echo "Generating SSH host keys..."
# Remove any existing host keys
rm -f /etc/ssh/ssh_host_*_key*
rm -f /etc/ssh/ssh_host_*_key*.pub
# Generate new SSH host keys
ssh-keygen -q -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N ""
ssh-keygen -q -t ecdsa -b 521 -f /etc/ssh/ssh_host_ecdsa_key -N ""
ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ""
echo "SSH host keys generated successfully"
\ No newline at end of file
...@@ -719,10 +719,19 @@ NETEOF ...@@ -719,10 +719,19 @@ NETEOF
print_status "No network configuration to apply - using defaults" print_status "No network configuration to apply - using defaults"
fi fi
# Generate SSH host keys for installed system
print_status "Generating SSH host keys for installed system..."
# Remove any existing host keys
rm -f "$TARGET_MOUNT/etc/ssh/ssh_host_*_key"*
# Generate new SSH host keys
chroot "$TARGET_MOUNT" ssh-keygen -q -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key -N "" || true
chroot "$TARGET_MOUNT" ssh-keygen -q -t ecdsa -b 521 -f /etc/ssh/ssh_host_ecdsa_key -N "" || true
chroot "$TARGET_MOUNT" ssh-keygen -q -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N "" || true
# Remove live-specific configurations # Remove live-specific configurations
rm -f "$TARGET_MOUNT/etc/systemd/system/getty@tty1.service.d/live-config.conf" 2>/dev/null || true rm -f "$TARGET_MOUNT/etc/systemd/system/getty@tty1.service.d/live-config.conf" 2>/dev/null || true
rm -rf "$TARGET_MOUNT/lib/live" 2>/dev/null || true rm -rf "$TARGET_MOUNT/lib/live" 2>/dev/null || true
print_status "Target system configuration completed" print_status "Target system configuration completed"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment