From owner-freebsd-questions@FreeBSD.ORG Tue Aug 30 18:42:11 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CF44106564A for ; Tue, 30 Aug 2011 18:42:11 +0000 (UTC) (envelope-from rsmith@xs4all.nl) Received: from smtp-vbr8.xs4all.nl (smtp-vbr8.xs4all.nl [194.109.24.28]) by mx1.freebsd.org (Postfix) with ESMTP id E12FD8FC15 for ; Tue, 30 Aug 2011 18:42:10 +0000 (UTC) Received: from slackbox.erewhon.net (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr8.xs4all.nl (8.13.8/8.13.8) with ESMTP id p7UIfd71099812; Tue, 30 Aug 2011 20:41:39 +0200 (CEST) (envelope-from rsmith@xs4all.nl) Received: by slackbox.erewhon.net (Postfix, from userid 1001) id 26216BA95; Tue, 30 Aug 2011 20:41:39 +0200 (CEST) Date: Tue, 30 Aug 2011 20:41:39 +0200 From: Roland Smith To: Michael Message-ID: <20110830184139.GA52397@slackbox.erewhon.net> References: <4E5D28E0.5050700@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="DocE+STaALJfprDB" Content-Disposition: inline In-Reply-To: <4E5D28E0.5050700@gmail.com> X-GPG-Fingerprint: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 X-GPG-Key: http://www.xs4all.nl/~rsmith/pubkey.txt X-GPG-Notice: If this message is not signed, don't assume I sent it! User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: by XS4ALL Virus Scanner Cc: "freebsd-questions@freebsd.org" Subject: Re: random generated password X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2011 18:42:11 -0000 --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 30, 2011 at 07:16:00PM +0100, Michael wrote: > Hello, >=20 > When adding a new user it is possible to assign a random generated=20 > password. But is it possible to assign a random password for already=20 > existing users? >=20 > Preferably in a non-interactive and scriptable way. Is it possible with= =20 > the base system tools? Generating a random password can be done with the openssl in the base syste= m; openssl rand -base64 9 You'd want to pipe the output of this command through tee(1) and save it in= a file. Next you pipe it to a file discriptor leading to a 'pw usermod -h 0'. Something like this: openssl rand -base64 9 | tee -a newpasswords | pw usermod UID -h 0 where UID is the user-id or name of the user in question. Roland --=20 R.F.Smith http://www.xs4all.nl/~rsmith/ [plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated] pgp: 1A2B 477F 9970 BA3C 2914 B7CE 1277 EFB0 C321 A725 (KeyID: C321A725) --DocE+STaALJfprDB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk5dLuIACgkQEnfvsMMhpyWoegCffcHKQEgzzTwIL3uFPAh5zDii wzAAn17rhvaWmO40TNJ9iQfKJ+wVK5W4 =N9ir -----END PGP SIGNATURE----- --DocE+STaALJfprDB--