From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,210744e06cbc2495 X-Google-Attributes: gidfee84,public From: pdchapin@news.amherst.edu (PAUL D. CHAPIN) Subject: Re: Help with passwd Date: 1995/10/02 Message-ID: <44pelu$m8p@amhux3.amherst.edu>#1/1 X-Deja-AN: 116901922 references: <44gf4c$g1h@hawk.ee.port.ac.uk> organization: Amherst College, Amherst MA, USA newsgroups: comp.unix.osf.osf1 Harald Fuchs (hf@colibri.de) wrote: : Matt Pound writes: : > Hi, : > I'm looking for a version of the passwd command or other method that would : > allow us to enter passwords as command line parameters instead of being : > prompted : > for them eg : > $ passwd : If you're absolutely sure you want to do something dangerous like that: : ask archie for "expect". One problem is getting the password to the expect script without it being visible to anybody who does a ps command with the proper options. The script itself is fairly simple, #!/usr/local/bin/expect -f # wrapper to make passwd(1) be non-interactive set password eeefff set username juser3 spawn passwd $username expect "quit):" send "p\r" expect "password:" send "$password\r" expect "password:" send "$password\r" expect eof This turns the problem of getting the password/username to how to edit the script each time. The quick and dirty solution to this is to create a file with the edit commands. The file name is visible with ps, but not the commands and, in particular, not the password itself. Now I have to update the edit commands each time. From the script that drives this mess I have # Set password on new account # This is ugly but I can't find another way to get variables to # the expect routine without making the password visible to ps echo "5s/set password .*/set password $PASSWORD/" > $BASEDIR/sedscript echo "6s/set username .*/set username $USERNAME/" >> $BASEDIR/sedscript sed -f $BASEDIR/sedscript $BASEDIR/passwdscript > $BASEDIR/script.tmp cp $BASEDIR/script.tmp $BASEDIR/passwdscript /usr/local/bin/expect -f $BASEDIR/passwdscript > /dev/null If somebody can come up with a less klutzy way of doing this I would like to know about it. Why do I do this, and why am I concerned that somebody may look as the ps listing when this is going on? At the beginning of each academic year I have to create something like 400 accounts. I don't want to have to run passwd 400 times. The entire process takes so long that, while the chance of any particular account being compromised is small, the change that one or more will is fairly high. I know because I didn't think of this the first year we ran the script and we had a problem with people noticing the passwords - fortunately responsible individuals who immediately warned me. The only other alternative, and what I did the first year, is kick off all the users until the new accounts are created, something that makes my users very cranky. -- Paul Chapin Unix Systems Manager Amherst College