January 9, 2010

If you were to tell me that you have never had to create a password for any kind of electronic account I would think that you lived under a rock or didn’t have a bank account.

I don’t know about you but for me the worst part about having a password for an account is creating one. Sure there are ones that are easy to remember, but are at the same time easy to guess. Such as you birthday or your anniversary. On the flip side, there are passwords that are near impossible to “break”, but they are also damn near impossible to remember. Well I’m not going to talk about how you should go about creating a password. If you really don’t know then I suggest you spend some time on Google or even CNN and NYT.

Instead I will discuss how you can use your computer to generate pretty strong (and “random”) passwords for you.  To do this we will make use of  /dev/urandom, cat, tr, and grep.  Suppose that you must create a password that has length 8 and contains at least one of the following characters !,*,&, and #, in addition to alphanumeric characters.  Well here is what you would enter to have your system create a list of, say 4, such passwords.

cat /dev/urandom | tr -dc 'a-zA-Z0-9!*&#' | fold -w 8 | head -n 4 | grep -i '[!*&#]'

Now instead suppose that your password did not have to have one of !, *, &, or #.  Then instead you could run:

cat /dev/urandom | tr -dc 'a-zA-Z0-9!*&#' | fold -w 8 | head -n 4

In addition to using /dev/urandom you could also use /dev/random for an even more secure password. For more information on this (and other aspects) go and read this post. It should answer some, if not most, of your questions.

To lean more about head and fold just go and read their man pages.  They are pretty straight forward.