From owner-freebsd-security Wed Dec 12 3:54:53 2001 Delivered-To: freebsd-security@freebsd.org Received: from rambo.simx.org (rambo.simx.org [194.17.208.54]) by hub.freebsd.org (Postfix) with ESMTP id EDD7E37B416 for ; Wed, 12 Dec 2001 03:54:45 -0800 (PST) Received: from rambo.simx.org (malin.twenty4help.se [195.67.108.195]) by rambo.simx.org (8.11.6/8.11.6) with ESMTP id fBCBsdC92410; Wed, 12 Dec 2001 12:54:40 +0100 (CET) (envelope-from listsub@rambo.simx.org) Message-ID: <3C1745CB.40305@rambo.simx.org> Date: Wed, 12 Dec 2001 12:55:55 +0100 From: "Roger 'Rocky' Vetterberg" User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011019 Netscape6/6.2 X-Accept-Language: en-us MIME-Version: 1.0 To: Noah Davidson Cc: "FreeBSD Security List (E-mail)" Subject: Re: password changes References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-freebsd-security@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Noah Davidson wrote: >How can I change the password of a user and not be prompted to verify >it. We are changing our mail server to sendmail. I have all of the >passwords in plain text. I want to write a script that changes all 5000 >or so passwords. How can I do this? I would like to call passwd or >some command from a perl script to do this. Any Ideas would be very >helpful. > I once needed to generate several thousands of users, with passwords from a plain text file. I did this using a perl script to write a new /etc/master.passwd and then rebuild using the pwd_mkdb command. Generating the needed lines and create the needed /home directories was easy, and to get the correct passwords I used the following code snippet: #!/usr/bin/perl $pass = pop(@ARGV); $cryptpwd = crypt($pass, &salt); print "$cryptpwd"; sub salt { local($salt); local($i, $rand); local(@itoa64) = ( '0' .. '9', 'a' .. 'z', 'A' .. 'Z' ); for ($i = 0; $i < 8; $i++) { srand(time + $rand + $$); $rand = rand(25*29*17 + $rand); $salt .= $itoa64[$rand & $#itoa64]; } return $salt; } Just put it in a file and execute it with the plaintext password as first argument, and the script will print the encrypted password to use in /etc/master.passwd. I dont remember exactly where I found this perl code, but it was ripped from one of the standard utilities in FreeBSD, probably adduser or something similar. Hopes this helps. -- R To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-security" in the body of the message