2

How can I generate a new random wpa/wap2 key in the linux terminal? I tried pwgen but this is not generating hexadecimal values.

dessert
  • 40,956

2 Answers2

3

For instance, if you want a password with the maximum character length, i.e. 63, you can enter either of the following 2 commands:

  1. makepasswd --chars=63

  2. openssl rand -base64 63

UPDATE:

Here is a better command I've found for this purpose since I first wrote this answer:

dd if=/dev/urandom bs=48 count=1 status=none | base64 | tr +/ -_

Actually I use this zenity-powered script to generate such a password from time to time:

#!/bin/bash
RNDPWD="$(dd if=/dev/urandom bs=48 count=1 status=none | base64 | tr +/ -_)"
echo $RNDPWD | tr -d '\n' | xclip -i -selection clipboard
zenity --question --title="Random Password" --text="<i>Password Copied to Clipboard:</i>\n\n$RNDPWD\n\n<b>Would you like to generate another one?</b>" --width=500 --height=150
if [ $? = 0 ]
then
    "~/.bin/Password-Generator-GUI"
fi
Sadi
  • 11,074
1

To generate the best possible password (with the highest entropy possible), one should use all of the ASCII printable characters - from 32 (space) to 126 (tilde, ~). This can be archieved with (for an example maximum password length of 63 characters):

< /dev/urandom tr -cd "[:print:]" | head -c 63; echo

To not include the space one can use [:graph:] character set and there are also others described in the tr's manpage.

drws
  • 181