I would recommend people stop using pwgen - its main interested was generating "human-rememberable passwords", but it showed multiple vulnerabilities in doing exactly that. And using it to generate completely random strings isn't that useful either.
I wrote a detailed article on that very topic, but basically, the gist of it is to use the diceware program (or, if you like dice, the actual diceware system) or xkcdpass. To generate strong memorable passwords, I generally use diceware with the following configuration file:
[diceware]
caps = off
delimiter = "-"
wordlist = en_eff
Examples:
$ diceware
turkey-eligibly-underwire-recite-lifter-wasp
$ diceware
lend-rubdown-cornflake-tint-shawl-ozone
$ diceware
syndrome-ramp-cresting-resolved-flinch-veneering
$ diceware
alto-badass-eclipse-surplus-rudder-quit
I turn off caps and spaces because they generate distinct audible noises that could be leveraged by an attacker. The -
delimiter is a lesser evil: it would be better to not use any separator and the en_eff
wordlist is especially crafted for that purpose. But I find it easier to communicate and share passwords when they have some separator.
To generate a completely random password, I use the following shell function:
# secure password generator or, as dkg puts it:
# high-entropy compact printable/transferable string generator
# a password generator would be pwqgen or diceware
pwg() {
ENTROPY=${1:-20} # in bytes
# strip possible newlines if output is wrapped and trailing = signs as they add nothing to the password's entropy
head -c $ENTROPY /dev/random | base64 | tr -d '\n='
echo
}
I mention this because I believe it is important to memorize less passwords and instead rely on a password manager to store large strings that are hard to guess. More details about the rationale behind those choices is explained in the aforementioned article and my password managers review.
2actually, there is an issue with this one-liner: it may use words like "the", "them", "their" and "moat", "iris", "he". Do you see the problem? There's an overlap between prefixes and suffixes, which reduces the actual entropy of the generated password and can lead to pretty weak passwords if the strings are not long enough (especially with 4 words). This is why word-based password generators use crafted word lists. Granted, passwords generated with the above are pretty good: 14 chars minimum in my tests, with a median size of 34. But their entropy is not reliable. – anarcat – 2017-08-31T19:13:12.153
What is the the issue with having overlapping prefixes / suffixes? I can understand your point about length, but you'll need to explain the other point. – James McMahon – 2017-09-12T02:20:16.000
let's simplify to the extreme. you have a dictionnary made out of three words:
the
,me
andtheme
. normally, you would expect you'd have the entropy equally from those three words, but in this case, you can't counttheme
because it is a combination of the other two words. in effect,theme
actually adds zero entropy to the password. – anarcat – 2017-09-12T14:07:04.817But isn't "the me" distinct from "theme"? I get that possible letters add entropy but this approach is more about the size of passwords. I don't get how "the me theme" would be easier to guess then a sequence with no overlapping characters like "do ray music" – James McMahon – 2017-09-13T00:15:37.643
the me
isn't distinct fromtheme
because you do not separate the words with spaces. the number of letters adds a certain amount of entropy, assuming that the attacker doesn't know how you generate your password. you can't assume that, especially if you publicly post about it. in that case, you must compute how much each word from the dictionary contributes to the entropy, and that's a different algorithm. as i mentioned here, i wrote a detailed article about how to evaluate that... – anarcat – 2017-09-14T01:49:26.157I like to use words of medium length that aren't obscure. So here's my variation of the answer:
curl -s "https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-usa-no-swears-medium.txt" | shuf -n4 | tr -d '\n'
. It requires you to be online to download the word list but the password generation itself is offline. – nofinator – 2019-05-01T17:30:18.800@anarcat I'd like to read your answer. I appreciate the other info you've provided so far. Will check out xkcdpass. – wbg – 2019-11-18T04:11:39.533
1
@wbg my answer is here https://superuser.com/a/1246245/177019
– anarcat – 2019-11-19T14:55:16.037