this script will reset a user’s password and email it to them.
It accepts two parameters (username) (email address)
Example Usage:
./reset_user_password.sh someuser [email protected]
#!/usr/local/bin/bash
if [ $# -ne 2 ]; then echo "Please provide a username and email address"; exit 0; fi
TMP_PASSWORD=$(openssl rand -base64 6)
echo "Resetting Password for $1"
echo $TMP_PASSWORD | /usr/bin/passwd --stdin $1
if [ $? != 0 ]; then exit 1; fi
echo 'Password reset.'
echo Sending notification email to $2
printf "To:$2\nFrom:Admin
echo 'Done.'