Chroot: small fix for printf and create /root/.ssh

This commit is contained in:
Jeremy Gardais 2019-04-03 23:44:53 +02:00
parent 166253b508
commit 17a32b701d
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 5 additions and 4 deletions

View File

@ -255,15 +255,16 @@ chroot /target update-grub
sed -i 's/\(^\|^\#\)\(PermitRootLogin\).*/\2 yes/g' /target/etc/ssh/sshd_config sed -i 's/\(^\|^\#\)\(PermitRootLogin\).*/\2 yes/g' /target/etc/ssh/sshd_config
### Add current authorized_keys from the rescue system if present ### Add current authorized_keys from the rescue system if present
if [ -f /root/.ssh/authorized_keys ]; then if [ -f /root/.ssh/authorized_keys ]; then
cp /root/.ssh/authorized_keys /target/root/.ssh/authorized_keys mkdir -p -- /target/root/.ssh/authorized_keys
cp -- /root/.ssh/authorized_keys /target/root/.ssh/authorized_keys
else else
printf '%b\\n' "${REDB}You might want to define an authorized key for SSH/root in /target/etc/ssh/sshd_config${RESET}" printf '%b\n' "${REDB}You might want to define an authorized key for SSH/root in /target/etc/ssh/sshd_config${RESET}"
fi fi
## }}} ## }}}
printf '%b\\n' "${REDB}Please change the root's password:${RESET}" printf '%b\n' "${REDB}Please change the root's password:${RESET}"
chroot /target passwd chroot /target passwd
printf '%b\\n' "${GREEN}The system is still available on /target but you can now try to reboot the hardware." printf '%b\n' "${GREEN}The system is still available on /target but you can now try to reboot the hardware.${RESET}"
exit 0 exit 0
# }}} # }}}