Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Jan 2007 08:00:57 -0800
From:      Michael <bsdquestions@gmail.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: Adduser utility to generate "random" passwds ?
Message-ID:  <45A3BC39.1050503@gmail.com>
In-Reply-To: <45A22099.3060208@esiee.fr>
References:  <45A22099.3060208@esiee.fr>

next in thread | previous in thread | raw e-mail | index | archive | help
Frank Bonnet wrote:
> Hello
>
> Is there a possibility to use as a standalone software
> the adduser feature that generate "random" passwd.
>
> I want to generate new "strong" password for existing users.
>
> Thank you
>
> Frank
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to 
> "freebsd-questions-unsubscribe@freebsd.org"
>
Another good choice for separate password generation is apg which is 
also in the ports.  What I like about apg is that it also provides a 
basic phonic for each password you can generate that helps you to 
remember your password.  As you may already know, having completely 
ambiguous random passwords isn't necessarily the best thing to use since 
most users will tend to write them down on paper somewhere and defeat 
the real purpose for generating good secure passwords in the first place.

Here is a small script that can generate these passwords via a web 
interface which is quite nice.  It does require that you have a ksh 
shell however since it was written with this shell in mind.

#!/usr/local/bin/ksh93

PATH=/bin:/user/bin:/usr/local/bin:/; export PATH
umask 077

a=/tmp/apg.$RANDOM
b=/tmp/apg.$RAMDOM

cat << EOF
Content-type: text/html

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
  <html>
    <head>
    <title>Help generating a new password</title>
    </head>

    <body>
    <h3>Help generating a new password</h3>

    <blockquote>
    These passwords should be reasonably safe.
    Feel free to use one, or reload the page
    for a new batch.</p>
    </blockquote> <pre> <font size="+1">
EOF

apg -q -m 4 -x 4 -M NC -E '!@#$%^&*()\\' -n 10 > $a
apg -q -m 4 -x 4 -M S  -E '!@#$%^&*()\\' -n 10 > $b

# tr command is for bug workaround; apg is not supposed to
# include characters specified after -E option

paste $a $b |   
    tr 'l' 'L' |
    awk '
      BEGIN {
        printf "Password\tRough guess at pronunciation\n<hr />"
        }
        {
        printf "%s%s\t%s %s\n", $1, $3, $2, $4
        }'

cat << EOF
    </font>
    </pre>
    </blockquote>
    </blockquote>
    <hr />
    </body>
  </html>
EOF

rm $a $b
exit 0

This script is from the book BSD Hacks, enjoy!

Michael Lawver




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45A3BC39.1050503>