by larrys · 14y ago · 0 comments
perl -le'print map { (a..z,a..z,0..9,"\$","!","-")[rand 65] } 0..pop' 7
Note this particular one only generates 7 digits with no UC. You can alter it to your taste or needs.
You can also wrap it in a shell script to generate a bunch in a row (in this case 10), like this:
for i in {1..10}
do
perl -le'print map { (a..z,a..z,0..9,"\$","!","-")[rand 65] } 0..pop' 20
done
As an aside I don't like any web based site that generates passwords (nor do you need that as just shown) since there is no way to know if the passwords generated are being logged along with some identifying information.
$ pwgen -1
enieQu3C
$ pwgen -1y
fa]m\e8O
$ pwgen -1sy 12
D[=,*j=65%
pwgen by default outputs a screenful of possible passwords. This is useful if two people are looking at the screen. -1 flag limits the output to a single password.
If I was generating initial passwords for someone's email account for example I probably would also leave out digits and letters that are easily confused, like 0 and O and l and 1 and some other things which isn't a best practice either but might be appropriate for other reasons.