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