Date: Tue, 30 Aug 2011 20:41:39 +0200 From: Roland Smith <rsmith@xs4all.nl> To: Michael <mlmichael70@gmail.com> Cc: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: Re: random generated password Message-ID: <20110830184139.GA52397@slackbox.erewhon.net> In-Reply-To: <4E5D28E0.5050700@gmail.com> References: <4E5D28E0.5050700@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Tue, Aug 30, 2011 at 07:16:00PM +0100, Michael wrote:
> Hello,
>
> When adding a new user it is possible to assign a random generated
> password. But is it possible to assign a random password for already
> existing users?
>
> Preferably in a non-interactive and scriptable way. Is it possible with
> the base system tools?
Generating a random password can be done with the openssl in the base system;
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
--
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)
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)
iEYEARECAAYFAk5dLuIACgkQEnfvsMMhpyWoegCffcHKQEgzzTwIL3uFPAh5zDii
wzAAn17rhvaWmO40TNJ9iQfKJ+wVK5W4
=N9ir
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110830184139.GA52397>
