Date: Sat, 14 Sep 2002 16:04:51 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Martyn Hill <m.hill@st-james-snrgirls.w-london.sch.uk> Cc: Questions FreeBSD <questions@FreeBSD.ORG> Subject: Re: How do I use the -h option in PW to set passwords fo rnew users Message-ID: <20020914150451.GA48316@happy-idiot-talk.infracaninophi> In-Reply-To: <000701c25bf5$2d8fa920$f801000a@maya.net> References: <000701c25bf5$2d8fa920$f801000a@maya.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 14, 2002 at 02:46:50PM +0100, Martyn Hill wrote: > I need to set-up about 200 user accounts under FreeBSD 4.5-RELEASE for the > school pupil and staff population. We run Samba-TNG to share files, but need > to create the UNIX users first. I intend to run a simple script to create > the users with a pre-prepared password. > > I've looked at PW but can't understand how the -h option is supposed to work > for setting initial passwords for new users. How do I specify the "file > descriptor" as described in the man page? > > I've tried creating a file containing the password and specifying: > > pw adduser ... -h /path_to_file_containing_users_password > You can use bourne shell to do that very easily: % echo "foobar" > /tmp/pass % su root -c sh Password: # pw useradd -n test -c "Test User" -m -h 3 3< /tmp/pass # grep test /etc/master.passwd test:$1$T2tu0BET$UGPrNB1FavzjlzhTwUWRN.:1002:1002::0:0:Test User:/home/test:/bin/sh # exit % su test Password: [typed "foobar" here...] $ exit The crucial bit is the '3<' construct: see the section on "Redirections" in the sh(1) man page for details --- bash(1), ksh(1), zsh(1) etc all support a similar mechanism, but csh(1) and tcsh(1) don't. You should probably use a file descriptor greater than 2 for this, as fd's 0, 1, 2 usually correspond to stdin, stdout and stderr respectively. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020914150451.GA48316>