Cool Password Script

Today I got a cool password script working to change a bunch of accounts and email the passwords encrypted with GPG.

pushd /run
touch $PWDFILE
chmod 0600 $PWDFILE
echo "New Passwords" >> $PWDFILE
date >> $PWDFILE
hostname >> $PWDFILE
hostname -i >> $PWDFILE
for USER in alice bob charles david
  PASSWORD=apg -M LNC -n 1 -m 16 -x 20
  echo -e $USER" " >> $PWDFILE
  echo -e $PASSWORD"\n"$PASSWORD | passwd $USER
rm -f $PWDFILE.asc
gpg -r -a -e $PWDFILE
rm -f $PWDFILE
echo "New passworda for "hostname | mutt -s "New passworda for "hostname -a $PWDFILE.asc

Works really well.

Weight: 299.2

This entry was posted in Technical, Training, Weigh In. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.