Shell script to update passwords for multiple users all at once.
Create a file with the list of account user names:
$ vim names.txt
user1
user2
user3
Create a script which will go through each username and execute the password update:
$ vim userupdate.sh
#!/bin/bash
for i in `cat names.txt`
do
echo $i
# set password to 123 for each user
echo $i"123" | passwd –-stdin "$i"
# for reset password at first login
chage -d 0 $i
done
Run the script:
$ chmod +x userupdate.sh
$ sudo userupdate.sh
This script was partially inspired by a how-to-forge article.
Create a file with the list of account user names:
$ vim names.txt
user1
user2
user3
Create a script which will go through each username and execute the password update:
$ vim userupdate.sh
#!/bin/bash
for i in `cat names.txt`
do
echo $i
# set password to 123 for each user
echo $i"123" | passwd –-stdin "$i"
# for reset password at first login
chage -d 0 $i
done
Run the script:
$ chmod +x userupdate.sh
$ sudo userupdate.sh
This script was partially inspired by a how-to-forge article.
Heu?
ReplyDelete`passwd` does not seem to have this --stdin option on Ubuntu 16.04, I even checked the man page....
Maybe you meant `mkpasswd` from the `whois` package ?
Merci pour le commentaire. ;-)
ReplyDeleteThis may not exist on Ubuntu, but it is a parameter in RedHat's passwd command option. =)
https://linux.die.net/man/1/passwd