A strong password is the most important way to keep your server secure.
A strong password should be comprised of at least 14 characters including lower case and upper case alphabetic characters, numbers and symbols and should never be based on a dictionary word.
The longer the password the harder it is to guess.
There are a number of ways to generate a password using the Linux command line.
It uses the openssl rand function to generate a 14 characters random string
openssl rand -base64 14
In this method, we filter the /dev/urandom output with tr to delete unwanted characters and print the first 14 characters.
< /dev/urandom tr -dc A-Za-z0-9 | head -c14; echo
pwgen is a tool that generates random meaningless but pronounceable passwords
To install pwgen, run the command
sudo apt-get install pwgen
Once the installation is complete, you can use the following command to generate a random string of 14 characters
pwgen 14 1
The gpg tool can also be used to generate a strong 14 characters password
gpg --gen-random --armor 1 14
There are many other ways to create a strong password from the command line.
You can also add a bash shell function to your ~/ .bashrc file