Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -o errexit
- set -o pipefail
- set -o nounset
- #set -o xtrace
- UFILE="/home/yourdir/users.txt"
- TFILE="/tmp/out.tmp.$$"
- OFILE="/home/yourdir/credentials.txt"
- for line in $(cat ${UFILE})
- do
- echo "User name: ${line} ... generating password"
- sleep 5
- mkpasswd -l 8 -s 0 >> ${TFILE}
- done
- paste -d':' ${UFILE} ${TFILE} > ${OFILE}
- echo "New passwords have been generated for the users!!"
- rm ${TFILE}
- sleep 5
- echo
- echo "Passwords will now be reset ......."
- sleep 5
- echo
- cat ${OFILE} > chpasswd
- sleep 5
- echo
- echo "User account passwords have been reset"
- exit
Add Comment
Please, Sign In to add comment