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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
-----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----- |
|
|||
|
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 |
|
|||
|
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. -- |
|
|||
|
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. |
|
|||
|
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 |
|
|||
|
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... ;-) |