"bulk" create of 400 users

This is a discussion on "bulk" create of 400 users within the Linux Security forums, part of the System Security and Security Related category; Hi all, I have to "bulk" create 400 users with username/password and home-dirs. Username and passwords ...


Go Back   Usenet Forums > System Security and Security Related > Linux Security

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-29-2005
Kay
 
Posts: n/a
Default "bulk" create of 400 users

Hi all,

I have to "bulk" create 400 users with username/password and home-dirs.
Username and passwords are available as a textfile in a non-crypted
format. Does anybody have an idea how to create 400 users with one step?

Any input is highly appreciated,
thx

Kay.
Reply With Quote
  #2 (permalink)  
Old 11-29-2005
Michael Zawrotny
 
Posts: n/a
Default Re: "bulk" create of 400 users

On Tue, 29 Nov 2005 11:17:54 +0100, Kay <csc15@arcor.de> wrote:
>
> I have to "bulk" create 400 users with username/password and home-dirs.
> Username and passwords are available as a textfile in a non-crypted
> format. Does anybody have an idea how to create 400 users with one step?


You can use the perl Crypt::PasswdMD5 module to create the list of
usernames and MD5-digested passwords (make sure to provide a new,
random salt for each user). Then wrap "useradd -p md5_passwd ..."
in a shell loop. This assumes that you are using the standard file
based authentication.

If this is a one-off situation, I wouldn't worry about the overhead
of spawning all of the useradd processes. If it is something that
has to be done frequently on a busy server, you may need to look into
something else (like LDAP or kerberos) that is more client-server and
scales better.

If you are using samba or LDAP as a distributed authentication scheme,
you can do something similar, but calling the tools appropriate for
that mechanism instead of useradd.

In the special case of LDAP, you can use perl or python to generate
one or more LDIF files and load them into the LDAP server.
Alternatively, you could use the scripting language's binding to LDAP
to work directly with the server instead of generating the file(s).


Mike

--
Michael Zawrotny
Institute of Molecular Biophysics
Florida State University | email: zawrotny@sb.fsu.edu
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
Reply With Quote
  #3 (permalink)  
Old 11-29-2005
Lew Pitcher
 
Posts: n/a
Default Re: "bulk" create of 400 users

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kay wrote:
> Hi all,
>
> I have to "bulk" create 400 users with username/password and home-dirs.
> Username and passwords are available as a textfile in a non-crypted
> format. Does anybody have an idea how to create 400 users with one step?


You could use the newusers(8) command to build all your users in one batch.

The manpage for newusers(8) says:

NEWUSERS(8) NEWUSERS(8)

NAME
newusers - update and create new users in batch

SYNOPSIS
newusers [new_users]

DESCRIPTION
newusers reads a file of user name and cleartext password
pairs and uses this information to update a group of existing
users or to create new users. Each line is in the same format
as the standard password file (see passwd(5)) with the
following exceptions...



- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFDjFn1agVFX4UWr64RAjghAJ0ZN26tw2kGFuuYWvKkWF KG80g3LACZAfgc
4oWbIlMFtuFdyx0+mG62vNw=
=13Wy
-----END PGP SIGNATURE-----
Reply With Quote
  #4 (permalink)  
Old 11-29-2005
Michael Zawrotny
 
Posts: n/a
Default Re: "bulk" create of 400 users


Lew,

On Tue, 29 Nov 2005 08:39:02 -0500, Lew Pitcher <Lew.Pitcher@td.com> wrote:
>
> You could use the newusers(8) command to build all your users in one batch.


Learn something new everyday. There was one thing that wasn't clear
to me from the man page that may or may not be important to the OP.
The man page says that pw_dir will be created if it doesn't exist and
it's ownership changed to that of the user. My question is whether or
not it populates a newly created directory with the contents of
/etc/skel the same way that useradd(8) does.


Mike

--
Michael Zawrotny
Institute of Molecular Biophysics
Florida State University | email: zawrotny@sb.fsu.edu
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
Reply With Quote
  #5 (permalink)  
Old 11-29-2005
matt_left_coast
 
Posts: n/a
Default Re: "bulk" create of 400 users

Michael Zawrotny wrote:

>
> Lew,
>
> On Tue, 29 Nov 2005 08:39:02 -0500, Lew Pitcher <Lew.Pitcher@td.com>
> wrote:
>>
>> You could use the newusers(8) command to build all your users in one
>> batch.

>
> Learn something new everyday. There was one thing that wasn't clear
> to me from the man page that may or may not be important to the OP.
> The man page says that pw_dir will be created if it doesn't exist and
> it's ownership changed to that of the user. My question is whether or
> not it populates a newly created directory with the contents of
> /etc/skel the same way that useradd(8) does.
>
>
> Mike
>


Give it a try and see.

--


Reply With Quote
  #6 (permalink)  
Old 11-30-2005
Ken K
 
Posts: n/a
Default Re: "bulk" create of 400 users

Michael Zawrotny wrote:

>
> Lew,
>
> On Tue, 29 Nov 2005 08:39:02 -0500, Lew Pitcher <Lew.Pitcher@td.com>
> wrote:
>>
>> You could use the newusers(8) command to build all your users in one
>> batch.

>
> Learn something new everyday. There was one thing that wasn't clear
> to me from the man page that may or may not be important to the OP.
> The man page says that pw_dir will be created if it doesn't exist and
> it's ownership changed to that of the user. My question is whether or
> not it populates a newly created directory with the contents of
> /etc/skel the same way that useradd(8) does.
>
>
> Mike
>


useradd does not do this automatically. Certain distributions have aliased
useradd to "useradd -m" which does this operation. I would imagine you
need to see what the default operation for useradd is. If it does not
create the home with skel, then set up the alias and try again. By the way
the man page reads, it calls useradd (proper), so an alias may do the
trick.
Reply With Quote
  #7 (permalink)  
Old 11-30-2005
Michael Zawrotny
 
Posts: n/a
Default Re: "bulk" create of 400 users

Ken K <kkauffman@nospam.headfog.com> wrote:
> Michael Zawrotny wrote:
>
> > On Tue, 29 Nov 2005 08:39:02 -0500, Lew Pitcher <Lew.Pitcher@td.com>
> > wrote:
> >>
> >> You could use the newusers(8) command to build all your users in one
> >> batch.


[ snip ]

> > My question is whether or not it populates a newly created
> > directory with the contents of /etc/skel the same way that
> > useradd(8) does.

>
> useradd does not do this automatically. Certain distributions have aliased
> useradd to "useradd -m" which does this operation.


That's more-or-less what I meant, except that I wasn't concerned
about the vendor supplied defaults and aliases.

When I said that useradd copied the skeleton to the user's directory,
I what I really meant was when invoked with "-m". My question was
whether or not newusers(8) had that same capability.

> By the way the man page reads, it calls useradd (proper), so an
> alias may do the trick.


Interesting. On the systems I have available (Ubuntu 5.x, old RH,
and old Slackware), the only mention of useradd(8) is in the see also
section. The man pages I have describe it as a sort of batch mode
hybrid between useradd(8) and usermod(8) and give no indication of how
it works.

If newusers really calls useradd (in the fork/exec sense), then it
wouldn't be noticeably more efficient than wrapping useradd in a shell
loop (aside from the shell approach needing to compute the digest form
of the password).


Mike


--
Michael Zawrotny
Institute of Molecular Biophysics
Florida State University | email: zawrotny@sb.fsu.edu
Tallahassee, FL 32306-4380 | phone: (850) 644-0069
Reply With Quote
  #8 (permalink)  
Old 11-30-2005
Kay
 
Posts: n/a
Default Re: "bulk" create of 400 users

Kay wrote:
> Hi all,
>
> I have to "bulk" create 400 users with username/password and home-dirs.
> Username and passwords are available as a textfile in a non-crypted
> format. Does anybody have an idea how to create 400 users with one step?
>
> Any input is highly appreciated,
> thx
>
> Kay.


The solution was quite simple: I used "webmin" to "script-create" 488
users... ;-)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:46 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0