Generate Strong Random Passwords On Ubuntu From the Terminal

With more and more cyber security breaches and recent compromise on the servers of Forbes and Sony, it became more obvious that you should create different strong passwords for each and every of your online accounts.

Those days are long gone when we used passwords like 'welcome' 'letmein' and '123456' (oops!). You should not use a password that could be easily guessed. Your password should be hard to predict and not related to anything on your life.

Around the web:

The characteristics of a strong password:

  • It is not a dictionary word.
  • Combination of uppercase, lowercase letters, numeric digits, special characters and symbols.
  • At least 8 characters.
  • Should not contain any part of your login id or user-name.
Considering the facts that you have to create a great strong password and also have to store it for future use; it becomes a hard job for you. So, we have came with a great solution to create a strong random password that is created by your computer and how you can store them easily so that you can use those later.

Creating the passwords from the command line:

You can use any of the following commands to generate a cool strong password on Ubuntu. Just copy and paste any of the commands below (at the end of the post) than press enter. It will generate a long password. You can change the number of characters from the command to create a longer or shorter password.


Storing the passwords:

Copy the password and paste it in a password manager software or just a simple text editor like I do myself. Don't forget to include the login id like the user-name or email. Then store that file in a secure place.


Commands to Generate Passwords:

You can use any of the commands below as many times as you want. The same command will generate a unique new password for you every time.
date | md5sum
openssl rand -base64 32
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6
date +%s | sha256sum | base64 | head -c 32 ; echo
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo
randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}
</dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo ""
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev

You can also find more interesting and useful commands on commandlinefu. There will be some commands that may not work for you. But you always have ton of other options. Share your thoughts on the comments below and let us know if this page was helpful for you.

Comments