pwgen -Bnyc

Generate pretty secure random passwords

These are my favourite switches on pwgen: -B Don't include ambiguous characters in the password -n Include at least one number in the password -y Include at least one special symbol in the password -c Include at least one capital letter in the password It just works! Add a number to set password length, add another to set how many password to output. Example: pwgen -Bnyc 12 20 this will output 20 password of 12 chars length.
Sample Output
yae[T3ae iM7ca[d9 joo*ro4K xoo}meF4 so{g9ohZ yohS&ah3 uu%X7jah fa|h7Wip
Siek'ei9 Oi:qu9ae uTh9gai[ Zei4ood: uRea7ab< Eequ[oo7 usa7pi|M Ooc(ei4d
Osh"equ7 Aip/ie3a ci)Ng7pi eiS3Vae] xoo4aaW. UTh3ahn[ yei^k9Ic Iu7Phah>
oas^iu9O voo4UaT' ooNg7oe| Xui"qu9o QuuT"oh7 buV9hei! inoo;N4E aiN,aex4
aighi%B7 Agh7tee! xo(fah3E Kah7aj\i ra9Aey(e aH[ai"y9 Oc(ai4Ee fe7MeX'u
ohj;ee3T osho*i7I Tai&Ng3e Koo,w?i3 ieB4Eef| Ahph:o4v VeiK+a4w oy3eeJ)u
ok9Fo>K^ oor!eeD4 aeR3phu& KiPo'ti4 woh&V3ox eiR!o4iz wooH*e9u Uef`oo9V
Ca9ein<e xa=na7Mo ooF"ie3W Eex;ai3c eiRai:z3 Si9sei&t eiY"ae7Z iH7eeG*o
UY7Pe@y7 que!X9th Eawiu"v4 Euxum$e4 Tua4Gie: os7bei<Z og=e4niR tho7Emo}
iey%uGa4 Awoh4se@ we3Weu@f Ahri>sh9 Ro7hu$uN ooGh,i9h Oow3ui*b ha9Ohr!a
sohD,ir9 UD<aePh7 roK4nai\ Jap7voh[ Voo9jei, wio4Vie< aQu7rah< bi.Geeg4
iu_koo9R Yu[th7yo Foh`d7yi Fok[ee9e zoo-ni4U Fah7aiZ! or!iah4H Ecae7xo-
OhS3Ef\i jooh7Be% OC3tei-M Eer3EeX| OiK}ah3p eeT7eov% aeN4Tho] uZ%io4ai
Pei|r9ai uuw;o7Oo gook/u9N iek[i4Ra Ies'oj7z Ahr_oo3e Aa9aiG@e ii.D7ohp
Yo$ce3wo coo"ph3I aex>ae9B IpooY}i9 wu3Thu%e Quei$H9g we9eM@uZ ooy4Ma#i
Pei=sh4r paiK&a7o eu7na^Pi dai@K3tu ooK!aen7 aD)a7dai oP'ij7Qu Aeng7ma-
aW9eezi< uu\vo4Ah kie=t9Pe eng7Eoj, eev9aeM" tah$qu7E eeHo|j4o Dahd>ee9
chuG:oh9 hi~k3ieP nah]C4ah jah4xaJ+ zooF`ai7 Ya@aY9fo EN]ohd7i ea3Chee%
Ee,f]i7i rau&K3Ce Ub7thah< eiN&ie9c Go7yuch! Aev3iqu$ ohr3EC*o oh7phu!W
ko3xae@C Oop&ee7i Iegh7ko- xo,Pie9h thee#Gu9 Boh+b4Ei ga4Je)qu eeV(o<s9

2012-03-15 14:38:15

These Might Interest You

  • The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memorable passwords are never going to be as secure as completely completely random passwords. [from pwgen man page] Show Sample Output

    pwgen 30 1
    sairon · 2011-07-24 19:43:48 0
  • Produces secure passwords that satisfy most rules for secure passwords and can be customized for correct output as needed. See "man pwgen" for details. Show Sample Output

    pwgen --alt-phonics --capitalize 9 10
    CafeNinja · 2009-10-24 08:36:36 3
  • Use the excellent to a generate random (yet easy-to-remember) password every second, and copy it to the clipboard. Useful for generating a list of passwords and pasting them into a spreadsheet. This script uses "madebynathan"'s "cb" function (; you could also replace "cb" with xclip -selection c Remove "while true; do" and "; done" to generate and copy only 1 password. Show Sample Output

    while true; do curl -s | tail -n 15 | head -n 1 | sed 's;<br/>;;' | cut -c 5- | cb; sleep 1; done
    supervacuo · 2012-01-30 20:52:14 0
  • Generate a table of random 10 character passwords Show Sample Output

    pwgen 10 # generate a table of 10 character random passwords
    mpb · 2012-10-26 08:57:47 0
  • According to the gpg(1) manual: --gen-random 0|1|2 count Emit count random bytes of the given quality level 0, 1 or 2. If count is not given or zero, an endless sequence of random bytes will be emitted. If used with --armor the output will be base64 encoded. PLEASE, don't use this command unless you know what you are doing; it may remove precious entropy from the system! If your entropy pool is critical for various operations on your system, then using this command is not recommended to generate a secure password. With that said, regenerating entropy is as simple as: du -s / This is a quick way to generate a strong, base64 encoded, secure password of arbitrary length, using your entropy pool (example above shows a 30-character long password). Show Sample Output

    gpg --gen-random --armor 1 30
    atoponce · 2011-07-20 15:32:49 2
  • Feel free to put this in your ~/.profile: random(){ cat /dev/urandom | env LC_CTYPE=C tr -dc $1 | head -c $2; echo; } Then use it to generate passwords: random [:alnum:] 16 Or DNA sequences: random ACGT 256

    cat /dev/urandom | env LC_CTYPE=C tr -dc a-zA-Z0-9 | head -c 16; echo
    yakovlev · 2014-02-05 15:04:07 0

What Others Think

Spoiler alert! date +%s | sha256sum | base64 | head -c 12 ; echo openssl rand -base64 9 < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-12};echo; gpg --gen-random --armor 1 9
Habitual · 322 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: