Fix password setup and SSH root login for installed system

- Modified live config hook to handle both crypted and plain text passwords
- Updated setup script to configure SSH for root login on installed system
- Set default root password to 'changeme' in preseed files
parent 5813d546
...@@ -150,12 +150,21 @@ PRESEED_FILE="/cdrom/preseed/debian-installer.cfg" ...@@ -150,12 +150,21 @@ PRESEED_FILE="/cdrom/preseed/debian-installer.cfg"
if [ -f "$PRESEED_FILE" ]; then if [ -f "$PRESEED_FILE" ]; then
CRYPTED_PASS=$(grep "passwd/root-password-crypted" "$PRESEED_FILE" | cut -d' ' -f4) CRYPTED_PASS=$(grep "passwd/root-password-crypted" "$PRESEED_FILE" | cut -d' ' -f4)
if [ -n "$CRYPTED_PASS" ]; then if [ -n "$CRYPTED_PASS" ]; then
echo "Setting root password from preseed..." echo "Setting root password from crypted preseed..."
# Set the crypted password directly in shadow file # Set the crypted password directly in shadow file
sed -i "s|^root:.*|root:$CRYPTED_PASS:1:0:99999:7:::|" /etc/shadow sed -i "s|^root:.*|root:$CRYPTED_PASS:1:0:99999:7:::|" /etc/shadow
echo "Root password set successfully from preseed configuration" echo "Root password set successfully from preseed configuration"
else else
echo "No crypted password found in preseed file" # Check for plain text password
PLAIN_PASS=$(grep "passwd/root-password password" "$PRESEED_FILE" | cut -d' ' -f4)
if [ -n "$PLAIN_PASS" ]; then
echo "Found plain text password, crypting it..."
CRYPTED_PASS=$(openssl passwd -1 "$PLAIN_PASS")
sed -i "s|^root:.*|root:$CRYPTED_PASS:1:0:99999:7:::|" /etc/shadow
echo "Root password set successfully from plain text preseed"
else
echo "No password found in preseed file"
fi
fi fi
else else
echo "Preseed file not found at $PRESEED_FILE" echo "Preseed file not found at $PRESEED_FILE"
......
...@@ -10,7 +10,7 @@ d-i keyboard-configuration/xkb-keymap select us ...@@ -10,7 +10,7 @@ d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto d-i netcfg/choose_interface select auto
# User accounts - predefined (root password set by set_root_password.sh) # User accounts - predefined (root password set by set_root_password.sh)
d-i passwd/root-password password changeme d-i passwd/root-password-crypted password $1$T6o3t4tQ$imuJB2Kmg.vBLvCBxyJgM0
d-i passwd/make-user boolean false d-i passwd/make-user boolean false
# Time configuration - predefined # Time configuration - predefined
......
...@@ -89,6 +89,37 @@ if [ -f "$TARGET_MOUNT/usr/local/bin/MbetterClient" ]; then ...@@ -89,6 +89,37 @@ if [ -f "$TARGET_MOUNT/usr/local/bin/MbetterClient" ]; then
echo "MbetterClient configured to start automatically" echo "MbetterClient configured to start automatically"
fi fi
# 7. Configure SSH for root login on installed system
echo "Configuring SSH for root login on installed system..."
if [ -f "$TARGET_MOUNT/etc/ssh/sshd_config" ]; then
# Enable root login
sed -i 's/#*PermitRootLogin.*/PermitRootLogin yes/' "$TARGET_MOUNT/etc/ssh/sshd_config"
# Enable password authentication
sed -i 's/#*PasswordAuthentication.*/PasswordAuthentication yes/' "$TARGET_MOUNT/etc/ssh/sshd_config"
# Ensure PubkeyAuthentication is enabled
sed -i 's/#*PubkeyAuthentication.*/PubkeyAuthentication yes/' "$TARGET_MOUNT/etc/ssh/sshd_config"
# Enable PAM
sed -i 's/#*UsePAM.*/UsePAM yes/' "$TARGET_MOUNT/etc/ssh/sshd_config"
echo "SSH configured to allow root login with password on installed system"
else
echo "Warning: SSH config file not found in installed system"
fi
# 8. Enable SSH service on installed system
echo "Enabling SSH service on installed system..."
if [ -d "$TARGET_MOUNT/etc/systemd/system" ]; then
# systemd system
chroot "$TARGET_MOUNT" systemctl enable ssh 2>/dev/null || true
elif [ -d "$TARGET_MOUNT/etc/init.d" ]; then
# sysvinit system
chroot "$TARGET_MOUNT" update-rc.d ssh enable 2>/dev/null || true
fi
echo "SSH service enabled on installed system"
echo "Installed system configuration completed!" echo "Installed system configuration completed!"
echo "" echo ""
echo "Installed system will now:" echo "Installed system will now:"
......
...@@ -17,7 +17,7 @@ d-i netcfg/choose_interface select auto ...@@ -17,7 +17,7 @@ d-i netcfg/choose_interface select auto
# d-i netcfg/wireless_key string # d-i netcfg/wireless_key string
# User accounts - predefined (root password set by set_root_password.sh) # User accounts - predefined (root password set by set_root_password.sh)
d-i passwd/root-password password changeme d-i passwd/root-password-crypted password $1$T6o3t4tQ$imuJB2Kmg.vBLvCBxyJgM0
d-i passwd/make-user boolean false d-i passwd/make-user boolean false
# Time configuration - predefined # Time configuration - predefined
......
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