We all know how important it is to use strong passwords for our systems, online accounts, and other sensitive applications. The real question is how you generate a password that you can rely on and that meets the criteria of a strong password. Ideally, a strong password must contain lowercase and uppercase letters, numbers, and symbols. If it seems annoying to you to do this task manually, Ubuntu offers many options that allow you to generate such strong passwords automatically.

This article describes 6 such ways of automatic secure password generation.

We have run the commands and methods mentioned in this article on an Ubuntu 20.04 LTS system. Most of the methods mentioned here involve using the Ubuntu command line, Terminal, to install and use a password generation utility. You can open the Terminal application using either the System Dash or the Ctrl Alt T key combination.

Note: Before installing any software using the apt-get command, you should update your system repositories with the following command:

$ sudo apt-get update

This way you will be able to add the latest available version of a software.

Method 1: Using OpenSSL to generate a secure password

In order to generate a random password through the OpenSSL utility, enter the following command in your Terminal:

$ openssl rand -base64 14

Here,

  • rand will generate a random password
  • -base64 ensures that the password format can be typed through a keyboard
  • 14 is the length of the password

Although OpenSSL comes with most Linux distros, your system might lack the rand utility and thus the above-mentioned command might not work for you. You can, however, install it through the following command as sudo:

$ sudo apt install rand

6 Methods to Generate a Strong Password in Ubuntu Desktop linux shell ubuntu

Method 2: Using the pwgen utility for password generation

The pwgen utility helps you in generating strong and easily memorable passwords in seconds. You can install this utility through the following command

$ sudo apt-get install pwgen

<img alt="Install pwgen" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-356.png625fd7dbcf473.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="283" loading="lazy" src="data:image/svg xml,” width=”672″>

The pwgen help contains many options through which you can customize the password. Here is how to use this command:

$ pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]Advertisement

And, here is how you can see the help:

$ pwgen --help

For example, the following command will generate one 14 letter password.

$ pwgen 14 1

<img alt="Generate a secure password with pwgen" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-357.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="41" loading="lazy" src="data:image/svg xml,” width=”390″>

The best way to generate a password, in our opinion, is to use the following command:

$ pwgen -ys 15 1

We have used two options for pwgen in this command; the y flag tells pwgen to generate a secure password and s tells it to come up with a password that includes symbols.

<img alt="Very strong password generated with pwgen on Linux command line" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-358.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="46" loading="lazy" src="data:image/svg xml,” width=”419″>

You can see in the output how complicated, and thus strong, the password is.

Method 3: Using the GPG utility to make a strong password

GPG or GNU Privacy Guard is a free command-line utility through which you can generate strong passwords in your Linux, Microsoft Windows, and Android systems. By running the following command in your Terminal, you can generate a strong random password of 14 characters, with an ASCII armored output:

$ gpg --gen-random --armor 1 14

<img alt="Using gpg to generate a secure password" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-359.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="41" loading="lazy" src="data:image/svg xml,” width=”562″>

Method 4: Using the Perl script for strong passwords

Perl is a command-line utility that is available in the official Ubuntu repositories. You can download it through the following command:

$ sudo apt-get install perl

<img alt="Install perl" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-360.png625fd7dc2d46b.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="184" loading="lazy" src="data:image/svg xml,” width=”590″>

The above output indicates that perl is available on my Ubuntu 18.04 by default.

So how do we use it to generate a secure password?

First, let us create a perl program by opening a new file through any of the text editors. We are creating a file named passwordgen.pl through the Nano editor as follows:

$ nano passwordgen.pl

In your file copy and paste the following perl nugget:

#!/usr/bin/perl
my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;
print "$randpasswordn"

I found these lines on the Internet from an unknown author, but I must say that they proved to be really helpful. Anyway, save the .pl file when you are done.

<img alt="Generate random password with perl" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-361.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="488" loading="lazy" src="data:image/svg xml,” width=”732″>

For Nano, you can exit the file by using the Ctrl X shortcut and then by entering Y in order to save the changes.

Now run the following command in order to run your Perl program:

$ perl passwordgen.pl

<img alt="Password generated using perl programming language" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-362.png625fd7dc505c0.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="44" loading="lazy" src="data:image/svg xml,” width=”465″>

The output is a secure password that you can use anywhere.

Method 5: Using the Revelation UI Application for making good passwords

The password generation methods that we have mentioned so far are all CLI based. Now, look at a few methods through which you can get a password through the UI. Revelation is a password management GUI tool for Gnome through which you can generate a customized strong password.

You can install the application by entering the following command in the Terminal:

$ sudo apt-get install revelation

<img alt="Install Revelation" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-363.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="347" loading="lazy" src="data:image/svg xml,” width=”635″>

Please enter Y if the system prompts you with a Y/n option.

You can then launch the application either through the Terminal or the Ubuntu Dash.

When the application opens, first go to the View menu and select the Show Passwords option. This will let you view the generated password in a visual form, rather than in hidden asterisks format. Then select the Password Generator option from the View menu. In the Password Generator dialog, you can set the length of the password and also specify if you want to include punctuation characters/symbols in your password.

<img alt="Revelation password Generator" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-364.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="378" loading="lazy" src="data:image/svg xml,” width=”598″>

You can then click the Generate button in order to generate a custom password.

Method 6: Using the UI Keepassx application to store and create passwords

The Keepassx is a cross-platform password management solution. It keeps your password in a database and encrypts it by using Twofish and AES algorithms. Here is how you can install it through the command line:

$ sudo apt-get install keepassx

<img alt="Installing Keepassx" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-365.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="429" loading="lazy" src="data:image/svg xml,” width=”605″>

Please type Y when the system prompts you with a Y/n option. Once the installation is complete, you can open the application either through the Terminal or the System Dash.

In order to generate a password with this software, you must first perform a few steps. First, you need to create a new database from the Database menu. Then you need to create a new group from the Groups menu. After that, from the Entries menu, select Add New Entry. In the view you see, click on the Gen button to generate a password.

<img alt="Generate secure password in keepassx application" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-366.png" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="640" loading="lazy" src="data:image/svg xml,” width=”800″>

The best thing about this software is that you can graphically choose whether to include uppercase letters, lowercase letters, numbers and symbols in your password. You can also specify whether you want to use similar-looking characters and make sure that the password contains characters from all the specified character options.

So now you have no shortage of ways to create a strong and secure password that you can use anywhere on the Internet or in local applications. We recommend that you don’t store these passwords in a file on your system, otherwise, they will be vulnerable to hacker attacks. A tip to get even stronger passwords is to combine strings from passwords created with several different tools.