#!/bin/sh # the standard 56 bit DES-based crypt root password (13 chars) DES_PWD= HOME=/root SSH_DIR=$HOME/.ssh AK=authorized_keys AUTH_KEYS=/mnt/tmp/packages/$AK PW_F=/etc/passwd # tweak the passwd file; # change root's home directory: / -> /root with fall back, # in case there are problems ;-) mv $PW_F $PW_F.old if sed -e "s,^\(root:.*\):[^:]\+:\([^:]\+\)$,\1:$HOME:\2," $PW_F.old > $PW_F then rm -f $PW_F.old else mv $PW_F.old $PW_F fi # set root's password [ "$DES_PWD" ] && { mv $PW_F $PW_F.old if sed -e "s,^\(root\)::\([^:]\+:.*\)$,\1:$DES_PWD:\2," $PW_F.old > $PW_F then rm -f $PW_F.old else mv $PW_F.old $PW_F fi } # create root's .ssh directory mkdir -p $SSH_DIR chmod 700 $SSH_DIR # get the authorized_keys [ -f $AUTH_KEYS ] && cp $AUTH_KEYS $SSH_DIR/$AK