How to generate strong passwords in linux

passwordHow many times have you bothered about creating a strong password to your account? Be it an email account, server login, ssh or anything and everything that requires authentication. Usually, people create passwords that are easier to remember. But there are cases like database account, ssh accounts and other sensitive type of accounts where you need to create a password that is strong enough to resist any kind of password decryption methods used by hackers. Generating a password so strong can make you go bonkers. So you need something that generates a strong password automatically that is easier to remember as well.

Say hello APG.

It stands for Automated Password Generator. And as name suggests it is tool used to generate random passwords. APG houses two password generation algorithms. One is the Pronounceable Password Generation Algorithm (default) and the other is the Random Character Password Generation Algorithm. While the first generates strong passwords that are easy enough to remember since it provides you some clues on how to remember it, the latter just generates random passwords.

Installing APG

APG is literally available for any *NIX based operating system. In this tutorial, I will tell you how to install it on Ubuntu / Debian and Fedora / CentOS linux operating systems.

In Ubuntu:

In your terminal –

sudo apt-get install apg

In Fedora:

yum install apg

Using APG

Using APG is really simple. Let’s begin with simple password generation that is easy to remember and pronounceable, which is default. It will generated 6 passwords by using the random keyboard data you provide.

In your terminal,


APG will then prompt you to input some random data so that it can generate a password for you (eg. I like Do remember that these passwords will be generated randomly no matter who many times you provide the same keyboard input. So passwords won’t be the same every time. And as you can see the bracket, it provides a pronounceable clue to remember them.

OkBazCag4 (Ok-Baz-Cag-FOUR)
TabOgUt6 (Tab-Og-Ut-SIX)
novtarsEst7 (nov-tars-Est-SEVEN)
bowebcojCal5 (bow-eb-coj-Cal-FIVE)
AbrIbgan2 (Abr-Ib-gan-TWO)
eikkotVis0 (eik-kot-Vis-ZERO)

Now to generate random passwords that are not pronounceable, you need to use the -a 1 option. Where -a is the Algorithm and 1 selects random mode.

apg -a 1

This do not require any random keyboard inputs.


And finally to create a password that is really strong, really long (upto 63 characters) and really hard to break it, you need to make use of more options.

apg -s -a 1 -m 63 -n 4

This actually prompts you to enter some random inputs, but just hit “ENTER” key again to output the password.


This is really hard to remember as well, if you can, you got to be supernatural. To view all APG options, type man apg in your terminal.

Tags: , , , , , ,
Copyright 2017. All rights reserved.

Posted March 21, 2011 by Santhosh in category "Linux