Friday, November 7, 2014

Random password in bash

Sometimes you may need to generate some random password. Bash can help you with that task. For any of the commands below you can modify them to adjust to your needs, i.e. modify the length or the logic.

16-character-long password based on date and base64/SHA encoding:

date +%s | base64 | sha256sum | head -c 16 ; echo

Another example using built-in /dev/urandom command:

< /dev/urandom tr -dc a-zA-Z-0-9 | head -c 16 ; echo;

Now the simplest command, which will work in any environment. 

date | md5sum

date | md5sum | head -c 8 

No comments:

Post a Comment