When setting up a new database connection for a web front end or other connection, I will use the command line to generate a random password. Since these are machine read and used passwords, there is no excuse to use a short password.

The following are my two preferred ways to generate a random password from the BASH shell. Please note that these generators will filter out some the less desirable characters like ‘, “, etc. which can often cause problems with configuration files:

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32}; echo;

The echo at the end just pushes the shell prompt to the next line. You can change the -32 to whatever length you want.

Optionally, you can use SHA to hash the date and base64 encode it.

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

For more ideas and ways to generate random passwords, visit the following site: 10 Ways to Generate a Random Password from the Command Line.