I'm trying to generate random pass of the users created by a text file in a bash script and then saving those passwords into a text file.. That's how I'm doing..
It works fine and creates user from text file and output the password as well well to lol file, but the passwords for created users wont work.
Here's my code, any help regarding that would be appreciated..
while read line || [ -n "$line" ] # protect against no newline for last line
do name=$line
pass=$(cat /dev/urandom| tr -dc 'a-zA-Z0-9' | fold -w 8| head -n 1 >> lol)
sudo useradd $name -m
sudo usermod -p $(echo $pass | openssl passwd -1 -stdin) $name
echo "The user - $name - has been created!"
done < "$fname" # double-quote fname echo
Aucun commentaire:
Enregistrer un commentaire