On Sunday 07 September 2003 2:40 am, jc fulknier wrote:
> is there a script to auto generate users and passwds
> into a mySQL DB?
Here is one I use:
=
#!/bin/sh
#
# usage: radadd
#
# creates a range of users from start to end with randomized passwords
# "format" should be a format string for the "seq" command, and is
# generally in the form "%0g"
# where "digit" refers to how many digits are in the "sequence"
#
rm /tmp/hgusers /tmp/hgpass
for uid in `seq -f"$1" $2 $3`;do
echo insert into usergroup values \(0,\"$uid\",\"$4\"\)\; >>/tmp/hgusers
echo insert into radcheck values [line continues]
\(0,\"$uid\",\"Password\",\"==\",\"`randpass`\"\)\; >>/tmp/hgpass; done
cat /tmp/hgusers /tmp/hgpass | mysql -h [continues]
-u -p
=
[when cutting/pasting, fix the "line continues" parts, and insert appropriate
for your MySQL database...]
the temp files, hgusers & hgpass, can be deleted afterwords or reviewed to see
what was added this time around.
the routine "randpass" generates the actual password -- this is my version,
but you can create one that makes passwords in whatever format you require
[upper vs. lower case, alpha vs. numeric, special symbols, length, etc.]
=
#!/usr/bin/perl
my $c="bcdfghjklmnpqrstvwxyz";
my $v="aeiou";
for ($i=0;$i<4;$i++) {print substr($c,rand(21),1),substr($v,rand(5),1)};
=
This deceptively simple routine generates passwords that are, for the most
part, pronounceable and rememberable without having to write them down [the
words look to be asian or hawaiian, though occaisionally a recognizable
english word will be generated, such as "rope" or "vase"] however since it
produces an 8-character password, you'll end up with "ropevase" as a password
--
Yet another Blog: http://osnut.homelinux.net
pgp0.pgp
Description: signature