# random passwords from manpages 2023-04-23T13:45:12Z 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 : ``` #!/bin/sh # Random memorable password from manpages # license: MIT # usage : rdmempw.sh (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 n++ 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. => gemini://si3t.ch/cgi-bin/pw I've updated my online password generator if you want to try. I guess it could be faster by using a cache. ## Comments? => mailto:bla@bla.si3t.ch?subject=random-passwords-from-manpages Comments by mail => /log/commentaires/ Mailing list instructions