> cd /

random passwords from manpages

Reading StackOverflow, I ran into a command to generate a list of words picked randomly in a wordlist or in a manpage.

I found the idea quite funny and challenged myself to make it a thing.

Find below a script to choose a random manpage on the system and pick randoms words to generate a memorable password :

# Random memorable password from manpages
# license: MIT <>
# usage : <words length> (default: 6)

# default is 6 words
[[ $1 -gt 0 ]] && w=$1 || w=6

# find a random manpage
manpage="$((apropos -s 1 .; apropos -s 5 .; apropos -s 6 .) |\
	sort -R |\
	awk '{sub("\\(.*|,", "", $1); print $1; exit}')"

man $manpage |\
	tr " " "\n" |\
	sort -Ru |\
	awk -v w="$w" '
	# keep only word at least 4 char long
	/^[[:alnum:][:digit:]]{4,}$/ {
		pw = pw $0
		if (n > w) { exit }
		pw = pw "-"
	END { print pw }

As you can see, "apropos" gives a list of availables manpages. I only use sections 1, 5 and 6 since the others are quite complex.

I use a lot of "sort -R" to randomize the wordlists.

Then, "awk" print the manpage, removing parentheses.

After, I call "man" and "tr" to replace every spaces with newlines so I can randomize with "sort" the wordlist. "awk" is used again to store words long enough in a string. When anough words are picked, we exit and display the password.

I've updated my online password generator if you want to try.

I guess it could be faster by using a cache.


Comments by mail

Mailing list instructions

[XHTML 1.1 valid] [CSS < 256B] [] [http/Tor]