Hi, does anyone know of, or can help me. I need a script/prog to change about 3500 users passwords to their usernames ???
Please!!???
Simon
On Mon, Jan 21, 2002 at 12:03:55PM +0000, Simon wrote:
Hi, does anyone know of, or can help me. I need a script/prog to change about 3500 users passwords to their usernames ???
have you got a list of usernames in a file? if so, you could do something similar to:
$ for user in `cat usernames`; do usermod -p $user $user; done
That should do it for you.
Thanks,
Brett Parker
On 21-Jan-02 brettp@users.sourceforge.net wrote:
On Mon, Jan 21, 2002 at 12:03:55PM +0000, Simon wrote:
Hi, does anyone know of, or can help me. I need a script/prog to change about 3500 users passwords to their usernames ???
have you got a list of usernames in a file? if so, you could do something similar to:
$ for user in `cat usernames`; do usermod -p $user $user; done
That should do it for you. Thanks, Brett Parker
Not sure this will help, since it looks as though the password argument to usermod -p has to be already encrypted:
usermod [-c comment] [-d home_dir [ -m]] [-e expire_date] [-f inactive_time] [-g initial_group] [-G group[,...]] [-l login_name] [-p passwd] [-s shell] [-u uid [ -o]] [-L|-U] login
-p passwd The encrypted password, as returned by crypt(3).
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 21-Jan-02 Time: 12:34:13 ------------------------------ XFMail ------------------------------
On Mon, 21 Jan 2002, (Ted Harding) wrote:
Not sure this will help, since it looks as though the password argument to usermod -p has to be already encrypted:
mkpasswd might be your friend here though, although i couldn't figure it out, maybe someody else can be bothered?
Adam
On Mon, Jan 21, 2002 at 02:42:31PM +0000, abower@thebowery.co.uk wrote:
On Mon, 21 Jan 2002, (Ted Harding) wrote:
Not sure this will help, since it looks as though the password argument to usermod -p has to be already encrypted:
mkpasswd might be your friend here though, although i couldn't figure it out, maybe someody else can be bothered?
OK, here goes nothing!!!
for user in `cat usernames`; do usermod -p `perl -e "$count = 0; $chars = ''; open RANDOM, '/dev/urandom'; while ($count < 2) { read (RANDOM, $char, 1); vec ($char, 7, 1) = 0; if ($char =~ /^[A-Za-z0-9]$/) { $chars .= $char; $count ++; }; }; close (RANDOM); print crypt $user, $chars"` $user; done
phew. that do ya? I'm not known as a nasty shell and perl hacker for nothing you know ;)
The chunk of perl makes a random seed and then crypts the username with it. I had that laying about, you know, as you do... forgot where I'd put it thou!
Hope that does what you want,
Cheers,
Brett - the not entirely awake, shell hacking, mad bastard - Parker
On 21-Jan-02 Simon wrote:
Hi, does anyone know of, or can help me. I need a script/prog to change about 3500 users passwords to their usernames ???
Please!!???
Simon
Hi Simon, Probably the program 'chpasswd' will do what you want. It should be available on any Linux system:
"man chpasswd" chpasswd - update password file in batch
SYNOPSIS chpasswd
DESCRIPTION chpasswd reads a file of user name and cleartext password pairs from standard input and uses this information to update a group of existing users. Each line is of the format
user_name:password
The named user must exist. The supplied password will be encrypted and the password age updated, if present.
This command is intended to be used in a large system environment where many accounts are created at a single time.
So, in your case, if you prepare a file "usr_pwd" in the form
user_name:user_name ....
you should then (as root) be able to do
chpasswd < usr_pwd
You may need to watch out whether the system dislikes short simple passwords (which usernames might be). I don't know whether this might fail on such cases.
You might also look at "man newusers".
Hope this helps! Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@nessie.mcc.ac.uk Fax-to-email: +44 (0)870 167 1972 Date: 21-Jan-02 Time: 12:20:04 ------------------------------ XFMail ------------------------------