How to generate strong passwords and check them from the terminal

create and check your strong passwords

In the next article we are going to take a look at some ways to generate strong passwords from the terminal. Today, the importance of a secure password that contains multiple letters, symbols, numbers, etc., is emphasized actively and passively, in order to strengthen it and not be an easy target for others when accessing our data. .

Everyone knows that today most platforms ask us for a password to access their services, our email, access to the office intranet, access to banks, etc., and if we do not have a solid password, sooner or later we may end up having serious security problems.

The typical points to consider to create a secure, stable and strong password are the following:

  • We must use symbols, numbers, uppercase and lowercase letters.
  • Do not use important personal or public dates, telephone numbers, identification document numbers, etc.
  • A good password should have a large number of characters. With this and following the previous considerations we will be able to make our password "almost" impossible to discover.

When we have to enter a password on one of our devices, we generally use one that is easy to remember. Needless to say, this supposes on many occasions a serious security breach that allows hackers to exploit them based on information they know about us or through brute force attacks. To improve this security, we must apply additional security measures, such as the use of random passwords that we can generate with different tools.

Next we are going to see several different ways with which we can create random passwords through a terminal of our Ubuntu, without the need for additional software. These passwords can be perfectly usable for all services that require a strong password. It goes without saying that randomly generated passwords are quite difficult to remember, so we will have to find a way to keep them handy.

How to generate strong passwords in Ubuntu

To write this article I am using Ubuntu 16.04. In Gnu / Linux we have some tools that give us the ability to automatically generate a secure password.

In case of not having these tools, we can install them using the following command sequence in the terminal (Ctrl + Alt + T):

sudo apt install gnupg2 && sudo apt install openssl

GPG

generate strong password with gpg

If we want create our password using GPG, we will execute the following command:

gpg --gen-random --armor 1 32

OpenSSL

generate secure password openssl

If we prefer use OpenSSL to generate our secure password, we will have to use the following command:

openssl rand -base64 32

APG

generate strong apg password

The other option that we can use to generate our secure password is APG, Abbreviation of Automatic Password Generator. It comes installed in Ubuntu and its derivatives. To launch the command we will only have to type in the terminal (Ctrl + Alt + T):

apg

It is a program designed to generate passwords "memorizable". If you simply run it, it will ask you for a series of data to work with, and based on that it will create a "memorizable" password. By this I mean that next to the password it will show us a phonetic transcription so that we can better remember the password.

Commands for the terminal

In addition to the tools that we have just seen, we will also be able to use a series of commands that will generate random passwords. You only have to write one of these lines in the terminal (Ctrl + Alt + T):

generate secure password terminal 1

date +%s | sha256sum | base64 | head -c 32 ; echo
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;  
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1 
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo 

generate secure password terminal 2

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32 
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev
</dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c32; echo ""
randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;} && randpw

Each time we execute any of these commands, the password that it will generate will be totally different and will not be related to any other previously generated.

How to check the strength of a password in Ubuntu

Many people may think that the password you are using is strong. To check if this is true, we will only need to install an application called cracklib. This analyzes all aspects of the password and gives us a result. To install cracklib in Ubuntu or Debian we will use the following command:

sudo apt-get install libcrack2

Set password

Once the application is installed we will use the cracklib-check parameter to check password status. For example, we will analyze a password that is too simple and popular. In the terminal we will write:

cracklib check

echo "1234abc" | cracklib-check

We can also check a strong password using:

cat|cracklib-check

We will have to copy the password to validate in the terminal and this command will show us the result. If the result is OK it indicates that our password is secure, now, we must be careful and keep this password in a safe place, in case we forget it.

Possible outcomes

cat cracklib check

We can obtain other results when analyzing our password. Some examples are the following:

  • It's too short
  • It is based on a word in the dictionary
  • It is based on your username

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   computer maintenance said

    The Ubuntu system is very interesting. And it is the first article that I see where they talk about how to create passwords in it, so anyone who has Ubuntu I will recommend this video
    I also want to highlight how well you have said the importance of words, and that we do not think that by writing words in another language we are going to get rid of being hacked, since hackers have techniques to guess them. Therefore, it is best to follow the steps of experts or articles like this one.