From: Michael Prokop Date: Thu, 25 Sep 2008 15:22:50 +0000 (+0200) Subject: Use random password if bootoption 'ssh' doesn't have an option. X-Git-Tag: 0.8.13~7 X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=commitdiff_plain;h=43634527f99d0f53449c3cb1b5d59b5bf195c74f;ds=sidebyside Use random password if bootoption 'ssh' doesn't have an option. --- diff --git a/autoconfig.functions b/autoconfig.functions index 6870e59..debf31f 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -1341,20 +1341,42 @@ fi # checkbootparam nocpu # {{{ autostart of ssh config_ssh(){ if checkbootparam ssh ; then - SSH_PASSWD="$(getbootparam 'ssh' 2>>$DEBUG)" - einfo "Bootoption passwd found." - if [ -n "$SSH_PASSWD" ] ; then - echo "grml:$SSH_PASSWD" | chpasswd -m - einfo "Starting secure shell server in background." - /etc/init.d/rmnologin start 1>>$DEBUG 2>>$DEBUG - /etc/init.d/ssh start 1>>$DEBUG 2>>$DEBUG & - eend 0 - else - eerror "No given password for ssh found. Autostart of SSH will not work." ; eend 1 - fi - eindent - ewarn "Warning: please change the password for user grml set via bootparameter as soon as possible!" - eoutdent + SSH_PASSWD='' + SSH_PASSWD="$(getbootparam 'ssh' 2>>$DEBUG)" + einfo "Bootoption ssh found, trying to set password for user grml." + eindent + if [ -z "$SSH_PASSWD" ] ; then + if [ -x /usr/bin/pwgen ] ; then + SSH_PASSWD="$(pwgen -1 8)" + elif [ -x /usr/bin/hexdump ] ; then + SSH_PASSWD="$(dd if=/dev/urandom bs=14 count=1 2>/dev/null | hexdump | awk '{print $3 $4}')" + elif [ -n "$RANDOM" ] ; then + SSH_PASSWD="grml${RANDOM}" + else + SSH_PASSWD='' + eerror "Empty passphrase and neither pwgen nor hexdump nor \$RANDOM found. Skipping." + eend 1 + fi + + if [ -n "$SSH_PASSWD" ] ; then + ewarn "No given password for ssh found. Using random password: $SSH_PASSWD" ; eend 0 + fi + fi + eoutdent + + # finally check if we have a password we can use: + if [ -n "$SSH_PASSWD" ] ; then + echo "grml:$SSH_PASSWD" | chpasswd -m + fi + + einfo 'Starting secure shell server in background.' + /etc/init.d/rmnologin start 1>>$DEBUG 2>>$DEBUG + /etc/init.d/ssh start 1>>$DEBUG 2>>$DEBUG & + eend $? + + eindent + ewarn 'Warning: please change the password for user grml as soon as possible!' + eoutdent fi } # }}} diff --git a/debian/changelog b/debian/changelog index df926f2..1688d60 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +grml-autoconfig (0.8.13) unstable; urgency=low + + * Use random password if bootoption 'ssh' doesn't have an option. + Thanks for the idea to Marc Haber! + + -- Michael Prokop Thu, 25 Sep 2008 17:22:17 +0200 + grml-autoconfig (0.8.12) unstable; urgency=low * Add support for swedish language settings. Contributed