From owner-freebsd-questions Sat Sep 14 8: 5: 2 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9FF8137B400 for ; Sat, 14 Sep 2002 08:04:59 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CC0543E42 for ; Sat, 14 Sep 2002 08:04:58 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk ([IPv6:::1]) by smtp.infracaninophile.co.uk (8.12.6/8.12.6) with ESMTP id g8EF4vGV048645; Sat, 14 Sep 2002 16:04:57 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.12.6/8.12.6/Submit) id g8EF4pFV048640; Sat, 14 Sep 2002 16:04:52 +0100 (BST) Date: Sat, 14 Sep 2002 16:04:51 +0100 From: Matthew Seaman To: Martyn Hill Cc: Questions FreeBSD 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> References: <000701c25bf5$2d8fa920$f801000a@maya.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000701c25bf5$2d8fa920$f801000a@maya.net> User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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