10 Ways to Generate Secure Passwords on Linux


It’s more crucial than ever to use strong passwords for your online accounts. Without a secure password, it’s easy for others to crack it. It’s great if you can come up with a good password on your own, but if you are out of ideas or feel like your own aren’t secure enough, you can get your computer to spit one out for you.

Here are 10 ways you can generate brand-new, secure passwords you can trust on Linux.

1. APG

The Automatic Password Generator, or APG, comes installed on all Ubuntu systems. It’s an easy-to-use utility that can give you various passwords based on random input from your keyboard. For example, you can run this command on Ubuntu Command Line Interface (CLI):


This will offer six “pronounceable” passwords. They’re meant to be pronounceable in order to make them somewhat more memorable, although the majority of them are still random.

If you’d like entirely random passwords, you can run:

 apg -a 1 

This command will give you passwords with eight to 10 completely random characters. Of course, this is also only after you’ve given it some random input using your keyboard.

passwords generated using apg displayed on ubuntu terminal

2. pwgen

pwgen is another utility that is just a quick installation away with the command:

 sudo apt-get install pwgen 

Once you have the password-generating tool on your system, run this command to generate passwords:


The command will flood your terminal with many passwords, so you’re just supposed to pick one at random (preferably not the first or last ones).

This is done in case someone is nearby or looking over your shoulder—that way, they won’t know which password you’ve chosen out of the many that are displayed.

passwords generated using pwgen displayed on ubuntu terminal

You can also use different flags to customize your password:

How to Generate One Password Only

Use -1 flag to generate one password rather than an entire screen full of them.

How to Generate a Password With a Different Algorithm

If you run the command using the -s flag, the password is generated using a different algorithm to make it even more secure.

How to Generate a Password With Special Characters

The -y flag adds special characters to the provided password.

How to Generate a Password Without Numbers

-0 flag generates a password that doesn’t include numbers.

How to Generate a Password Without Complex Characters

-B flag does not allow the use of characters that are hard to read, such as 1 I l or 0 O

How to Generate a Password Without Vowels

The -v flag does not allow any vowels. This is primarily used if the website doesn’t allow offensive language to be used in passwords.

3. makepasswd

makepasswd is yet another utility that makes generating passwords straightforward. You can install it with this command:

 sudo apt-get install makepasswd 

From there, you can create some passwords with this command:

 makepasswd -count X -minchars Y 
passwords generated using makepasswd displayed on ubuntu_

Replace “X” with the number of passwords you want and “Y” with the minimum length of each password. It is also flexible enough for other users.

For example, the following command will give you a randomized numerical-only password with only four digits, i.e. a PIN (Personal Identification Number):

 makepassword -string 1234567890 -chars 4 

4. passwordmaker-cli

If remembering your passwords is the hardest part about using secure logins, then passwordmaker will be your new best friend. You can install it using this command:

 sudo apt-get install passwordmaker-cli 

To use this command-line utility, run:

 passwordmaker --url makeuseof.com 
A password displayed on terminal that was generated using passwordmaker

Replace “makeuseof.com” with another website of your choice. It will then ask you for a Master Password before giving you a secure one.

The good thing about this tool is that you can use the same Master Password and get different passwords for different sites. If you forget a password for a certain site, you can run the utility again with the same website and Master Password, and you’ll get the same secure password. This will likely remind you of password managers.

5. Manually with Well-Crafted Commands

You can also try to use some well-crafted commands to make your own passwords, without having to rely on special utilities to generate them. For example, you can use the below command to create a password, and it will always be unique because it is based on the current date, including seconds:

 date +%s | sha256sum | base64 | head -c 32 ; echo 
A password displayed on terminal that was generated using a self-crafted linux command

​​​​Another example that’s easier to remember (the command, that is, and not the password it generates) is:

 date | md5sum 

6. OpenSSL

OpenSSL helps generate passwords too. Using the rand function, you can have many random secure passwords on Linux. All you need to do is specify the length of the password you want to generate.

Many Linux distributions come pre-installed with OpenSSL; however, they may not have the rand function. For this, you need to install it on Ubuntu using the APT command:

 sudo apt install rand 

Once the function is installed, you can generate a password using the following command:

 openssl rand -base64 14 
password generated using openssl displayed on terminal

“14” is the length of the password, but you can use any length for your password.

7. GPG utility

One more method that is widely used to generate passwords is GPG. It is also a command line tool available on Linux, Windows, and Android. To create a 16-digit password, for instance, you can execute the command like this:

password generated using gpg displayed on ubuntu terminal

8. Perl Script

You can also make use of Perl script to generate as many passwords as you want on a Linux system. To install perl on Ubuntu, use the apt-get command:

 sudo apt-get install perl 

Once installed, create a perl file in which you will add a script to generate passwords. Create a script file with .pl extension using the nano editor:

 nano passwordscript.pl 

Add the following contents in the .pl file:


my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);

my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;

print "$randpassword\n"

password generation script file contents are displayed

To save the file, press Ctrl + X, then Y, and hit Enter.

Now, execute the script using the perl utility to generate a password:

 perl passwordscript.pl 
password generated using perl script displayed on ubuntu terminal

9. Revelation UI Application

If you are not comfortable using the Linux command line, you can use applications that have a user-friendly Graphical User Interface (GUI) to generate passwords. One such tool is Revelation. To install Revelation on Ubuntu, issue this command:

 sudo apt-get install revelation 

When launched, go to View > Password Generator to open the password generator window. Here, you will provide the length of the password you want to make. You can also select the box at the bottom if you’d like to have punctuation in the password to make it more complex.

To generate a password, click on the Generate button.

a password generated using revelation displayed

10. UI Keepassx

Another GUI application that you can use to generate passwords is Keepassx. It is a password management tool that is also easy to install and use on Linux. To install Keepassx on Ubuntu, execute:

 sudo apt-get install keepassx 

Now, launch it and click on Database > New Database. Here, you will provide a master key and then click Okay. Next, go to Groups > Add a new Group. Give a name to the group and hit Okay. After that, click on Entries > Add New entry.

To generate a password, press the Gen. button located on the right-hand side. You can also specify the length of the password you want and which characters you want to use.

A password generated using keepassx displayed

What Do You Use For Passwords?

There are loads of ways to generate secure passwords on Linux, so there’s no excuse not to.

The important thing is to keep your passwords secret and secure. No matter how many tools you use to generate long complicated passwords, in the end it is all about keeping them in a place where they are safe. Anyone can trick you into revealing passwords. Make a rule to trust no one with your login details, no matter what.


Source link

Leave a Reply

%d bloggers like this: