Article thumbnail

Generate some easy to remember passwords

17 March, 2016Linux

Do not use this for sending sensitive data! For that please use a public key encryption scheme like PGP or GnuPG. This below is suitable for things such as online logins etc.

Obtain word list

Prepare a text file with dictionary words. Here we download some word lists from Scowl.

wget "http://downloads.sourceforge.net/wordlist/scowl-2016.01.19.tar.gz" && \
tar -zxvf scowl-2016.01.19.tar.gz --wildcards --strip-components=2 scowl-2016.01.19/final/english-words.*

We grab the file english-words.10 and english-words.20 which contain a lot of popular words, filter it and remove the words we don’t want. There are other files here too which you can use as well, though they may contain less commonly used words which may be more difficult to remember.

To make a word list from english-words.10 and english-words.20 with 5 chars or more

cat english-words.10 english-words.20 | grep -v "'" | grep -e "....." | uniq | xz -9 -e > words.txt.xz

On Mac OSX, you’ll need to set LANG=C otherwise you’ll get a charset error with uniq.

Count the number of words in the list. For my current test, there is 9481 words.

xz -dc words.txt.xz | wc -l

Generate a 4 word password

Let’s random sort and create a password with 4 words. We’ll capitalise the first letter as well.

On Mac OSX, install coreutils and gnu-sed on Homebrew.

Linux

xz -dc words.txt.xz | sort -R | head -n 4 | sed 's/^\(.\)/\U\1/' | tr -d '\n'

Mac

xz -dc words.txt.xz | gsort -R | head -n 4 | gsed 's/^\(.\)/\U\1/' | tr -d '\n'

Make 10 random 4 word passwords

The above command repeated 10 times.

Linux

for i in {0..9}; do xz -dc words.txt.xz | sort -R | head -n 4 | sed 's/^\(.\)/\U\1/' | tr -d '\n'; echo ""; done

Generate 10 random 3 word passwords

Make 10 random 3 word passwords

Linux

for i in {0..9}; do xz -dc words.txt.xz | sort -R | head -n 3 | sed 's/^\(.\)/\U\1/' | tr -d '\n'; echo ""; done

Mac

for i in {0..9}; do xz -dc words.txt.xz | gsort -R | head -n 3 | gsed 's/^\(.\)/\U\1/' | tr -d '\n'; echo ""; done
© Andy Gock 2009−2023