SUMMARY: Mass-adding user accounts under Enhanced Security

From: Jane Kramer <Jane.Kramer_at_oberlin.edu>
Date: Tue, 12 May 1998 13:41:04 -0400

Original post by Jane Kramer:
>
> Hello,
>
> We're configuring a new system here, running Digital UNIX 4.0D with
> Enhanced Security. I want to write a script or program to mass-add
> accounts (we have an influx of new students every Fall), invoking
> useradd. As far as I can tell, useradd is the best utility for doing
> this.
>
> Has anyone done this, *and* been able to set pre-determined passwords
> (all of which are different) for the accounts via the script?

Thanks to all who replied. The key to the problem is that under
Enhanced Security, the password is not stored in /etc/passwd, and the
useradd command does not have an option to set passwords.

The solution to mass-adding accounts is to write a script (in the form
of your choice: Perl, Csh, whatever) that essentially does the
following:

        read input-file-containing-list-of-users-and-passwords
        for each user
                invoke 'useradd' with correct arguments
                invoke Expect script to set password
        end

Here's a copy of an Expect script that works with the Enhanced Security
version of 'passwd':

#!/usr/local/bin/expect -f
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg,
# password type is passed as 2nd arg,
# desired password as 3rd

set pick [lindex $argv 1]
set password [lindex $argv 2]
spawn passwd [lindex $argv 0]
expect "choice:"
send "$pick\r"
expect "password:"
send "$password\r"
send "\r"
expect "password:"
send "$password\r"
expect eof



Information on Expect is available at
http://elib.cme.nist.gov/pub/expect.

Tcl (required by Expect) is available at ftp://ftp.smli.com/pub/tcl/.

-- 
====================================================================
Jane Kramer                            
Computer Systems Manager, Oberlin College
Jane.Kramer_at_oberlin.edu
440-775-6929
====================================================================
Received on Tue May 12 1998 - 19:42:09 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT