Saturday, June 23, 2007

Setting a lot of user passwords at once

Say you have a whole class of users who have lost their passwords. Or perhaps you've just created a set of users with some automated method that doesn't allow you to easily set their passwords (such as a scriptfile full of useradd commands).

You'll want to use a file containing the following information:

user1:passwd1
user2:passwd2

Then run the command:

cat passwords.txt | chpasswd

Don't forget to delete your passwords.txt file just after you're done. Seriously bad idea to leave this file hanging around.

If you're looking for a way to automatically generate a whole bunch of passwords that your users won't balk at, the pwgen command may be installed on your system already!

If not, and you don't want to go hunting for one, try this: http://www.multicians.org/thvv/gpw.html

No comments: