From de35719b12afc15f116de7c3e849f5113ce98d1e Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 3 Apr 2019 17:03:48 +0200 Subject: [PATCH] Chroot: include openssh-server and add keys --- debian/chroot.install | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/debian/chroot.install b/debian/chroot.install index bdc91c5..9d57827 100755 --- a/debian/chroot.install +++ b/debian/chroot.install @@ -30,7 +30,7 @@ RESET='\033[0m' ## Package to exclude from debootstrap install dbs_pkg_exclude="vim" ## Package to include to debootstrap install -dbs_pkg_include="aptitude,bzip2,debconf-i18n,dialog,dmsetup,htop,isc-dhcp-client,isc-dhcp-common,locales,lvm2,pciutils,tmux,vim-nox,wget,zsh" +dbs_pkg_include="aptitude,bzip2,debconf-i18n,dialog,dmsetup,htop,isc-dhcp-client,isc-dhcp-common,locales,lvm2,openssh-server,pciutils,tmux,vim-nox,wget,zsh" # Partitionning {{{ if [ "${manage_part}" -eq 0 ]; then @@ -201,7 +201,16 @@ sed -i 's;/target;;g' /target/etc/fstab ## }}} # }}} # Finish {{{ - +## SSH {{{ +### Allow root connections - this should be fixed if it works +sed -i 's/\(^\|^\#\)\(PermitRootLogin\).*/\2 yes/g' /target/etc/ssh/sshd_config +### Add current authorized_keys from the rescue system if present +if [ -f /root/.ssh/authorized_keys ]; then + cp /root/.ssh/authorized_keys /target/root/.ssh/authorized_keys +else + printf '%b\\n' "${REDB}You might want to define an authorized key for SSH/root in /target/etc/ssh/sshd_config${RESET}" +fi +## }}} printf '%b\\n' "${REDB}Please change the root's password :${RESET}" chroot /target passwd