From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078708811539.tru64-unix-managers.marc@archive.invalid> From: Jane Kramer Date: Tue, 12 May 1998 17:41:04 +0000 To: tru64-unix-managers Subject: SUMMARY: Mass-adding user accounts under Enhanced Security X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078708811539 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@oberlin.edu 440-775-6929 ====================================================================