How to generate secure passwords in Linux

Posted by Tully on Sat 28 September 2013

When creating a new password there is basic guidelines you should follow. Keep in mind that a strong password still does not replace the need for other effective security controls. I recently created a simple BASH script to generate passwords. This included all the basics steps to a strong password. (Shown below)

Strong password guidelines:

  • 7+ characters in length.
  • Does not contain a dictionary word.
  • Includes both lowercase and uppercase characters.
  • Must include a number.
  • Must include a symbol.

After creating the password BASH script, I came across a tool called pwgen. Pwgen is a password generator that is included in the epel repository. It generates a list of secure passwords for you.

The description found in the man pages for pwgen is as follows:

The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memorable passwords are never going to be as secure as completely completely random passwords. In particular, passwords generated by pwgen without the -s option should not be used in places where the password could be attacked via an off-line brute-force attack. On the other hand, completely randomly generated passwords have a tendency to be written down, and are subject to being compromised in that fashion.


$ pwgen

weeGhae6 Chi0ix8y We6Phaiv Tohaex5W aiGho5re jae7IZem Zeesah9l eeshoh1K
Eng0ohqu eS5aeth2 Chailei8 Eew7eiso kai7eiTh Ux0chooh daaZi9wo phaic7An
NieYii6y Bo4OoSh6 xei9ae2S Eich7ahz xai5aGh5 ohroh7uN eew6Edoo mahXohc7
za2aeMie il8hi2Ce Ohb4eola eeviaF5v uth2Aef7 KaiZu6Ch ao6zaBu4 quu5aeR2
ouw1ceiJ ohmee3Ae uuGoa5du shie5Aep Quor0Ohv tooB1aef ohdiwaC2 ahp3ieWe
me1OhHeo AhB4thoh ooth8Oof iePoo1ie Hei9ohwu eS1ohnee Too6Yeit ua4Iyaew
va7Ooqu0 ieChae8i Ahc4Sai0 Loo8eit8 doo1Ahgi nai7AaG0 Lohpi7la OoZocho4
Ohfie0qu ooP5seiL ohYa4pho Shah7upa ieCuto6o laN0jiej Quae9eiM aec6Bish
Euqu8je9 Ahcai9ok EiNgee0a eZo3aera Eish6chu ohP1agei Wi8ohQuu uish0Tha
oon3XaeM se6Aiz0w ooNg2jeo gohp2EeZ eiNeer8x keepie3I ZiMouy6h ees3Foh5
Aekuu7os Yee2ohth Ci6chore chies9Th ohhei9Qu AdaJ9pha gaiD0uod sai2ooCi
ooTith5g Uiz0uci3 iD0kae4O voh8Ooxo uased6We Yai7HeiZ Biubie9a Ieth5va8
NahveiK6 aiB6ato4 iec5Aes8 Nibei7sh aePhie2x eiZ1xaiB paeC0eet eeGhoh8w
uo9quohJ Quien8oe Doofu8Ar ohk8Ih5z eeghe8Ee Yie7eeLa fei5Ahto queeRah1
xuad3Iri eePua3eS Ucheph6Y uhul3Ahp Ix1cos3U vae6Hohd ohSae5aJ Thahqu9K
Xah4tahf Aing0aes joh0eeDe Haequie7 ahng8ieD faeb5aiJ Ahh0gi9o Euvah6Ai
Ochove4d io2eiVoi kohG1Que Ieth8Eoh yohm3eiK gah1Cuv5 ugah3Doo pie3riQu
joe4cuCi OoMah6ie xiewoo1P Quaefai1 thi9eK9l Ahxein3O oapied5Z Nul8bequ
ohZoh9ye ooPhaef8 theeWi6e ri3Ooghi IBoh5oce iewai7Ch cei6Phah bie2Eelu
aSh4aing Boo1moos uh3piu1U quo3thaL chai0Hup xae9Ahqu ooVu0eib niG4lahz