Generate strong WPA2 passwords with Ubuntu

To secure wpa/wpa2 keys from brute-force or dictionary-attacks, it is evident to use strong, that means long and purely randomly generated keys, which are in addition generated with a strong algorithm.

WPA/WPA2 limits the length of passwords to 63 digits, including upper/lowercase and special characters – so that’s what we are trying to generate….

There is a versatile tool for Ubuntu available – apg.

Install it via

sudo apt-get install apg

Now, let’s use the full length available for WPA2 and generate some passwords with apg using:

apg  -m 63 -x 63 -a1

To parse the keys automatically into a file, so that you can store and copy&paste the password, use this command:

apg  -m 63 -x 63 -a 1 > password.txt

Both commands will generate 6 very strong and purely random passwords. You can use the file later to copy&paste the password into your network settings.

One thing:

surprisingly, some passwords include (though ASCII) characters, which might give you some problems within the network configuration, especially those, which cause a special behavior of the bash. To be sure, that your generated password won’t cause those problems, paste the password in this command:

echo "your-pass-word-with-special-characters"

If the displayed password is different than the pasted or especially, if the bash displays a syntax error, then change the displayed errornous character with for instance #.

Leave a Reply