Local Accts Bulk Add

From: Angelo McComis (sunmanagers@mccomis.com)
Date: Wed Feb 16 2005 - 08:54:07 EST


I have a need to add about 200 accounts to a local system.

I've been given the initial passwords, and I'm not looking to require
changing them at login (they're actually not shell accounts, mail only,
so the concept of logging in will not "apply" to these people).

The system is Solaris 7 (I know.. I know...); using local accounts
(/etc/passwd, /etc/shadow).

The UIDs can be the next available uid, the GID is just a normal GID.

The home directory should be created in the normal way (e.g.
/export/home/username)

The shell can be /bin/false

I have the list in a Spreadsheet with user full name, and their assigned
initial password.

What I did:

Took the Excel spreadsheet and in another tab, grabbed the full name and
broke it into two columns, first name, last name (split at the first space).

Took those two columns, and did a left(first name, 1) to get the first
initial and right(last name, 7) to get a username that is a max of 8 chars.

Crafted a concatenate formula that when assembled, resulted in this:

useradd -g 100 -c "Robert Johnson" -s /bin/false -m rjohnson

Copied that field of "strings" into a useradd.sh script.

Now for the passwords:

Created another tab that took the username and creates a concatenate
formula that resulted in this:

echo `htpasswd -dnb rjohnson RJ1203rj`::::::: >>shadow.tmp ; sleep 1

Copied that field of "strings" into a mkshadow.sh script.

Copied both .sh scripts to the box and ran them.

After running the mkshadow.sh script, I replaced the appropriate lines
in the /etc/shadow file with the lines containing the hashed passwords.

This Worked... But I'm looking for something that's less complicated.
(Imagine that)

The challenge I ran into was getting a plain text password converted
into the UNIX-style hashed password reliably.

The sleep 1 in the mkshadow script is because it ran too fast, using the
same salt for several accounts in a row.

Looking for any other creative ways this might be accomplished.

Thanks,

Angelo
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:30:11 EDT