How to create strong passwords in Linux

Most Linux servers still use password-based authentication for local and remote login. Since server hacks are on the raise, it's important to have in place schemes to secure your server.

Now I strongly recommend you use passwordless key-based authentication especially when SSHing into remote boxes, but if you choose to go with passwords either for logging in or setting database passwords, here are some tools you can use to create strong passwords.


By far pwgen tool is my favorite commandline tool for generating secure passwords. The tool is available on the Ubuntu repository so you can use apt-get to install it like;

sudo apt-get update sudo apt-get install pwgen

Now you generate random passwords by simply running pwgen.
dokwii@davebeast> pwgen zo2aa7Ic aijooL4V osh9Aer9 thie9Ov9 ahPaeVa2 ueY2phoo Shiequ2a Ha3aew5f

Other options

You can even to choose stronger ones by specifying the number of characters and that is should contain special characters with the -y option like so;

dokwii@davebeast > pwgen -sy 13 G,f?>J{+4|bx4 Oy(I8.&!.mNzY O@'pWA3c5%.A] {'$>Cq0:ja(o( <2nq|KG|q@Ztp

The other options include using Linux terminal inbuilt commands;

run date | md5sum and you get something like

and also run date +%s | sha256sum | base64 | head -c 32 ; echo which would output something like MjFhNjVhM2U1Zjg3ZjY1ZDVmZjdlZjVk.

The last two methods are great when writing a shell scripts and you have a function that generates random secure passwords.

David Okwii

David Okwii is a Ugandan-based Technology writer and System's Engineer.

Kampala Uganda

Subscribe to oquidave@geek:~ #

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!