Tuesday, August 25, 2009

Generating strong passwords

Sometimes we need to make up the password. Normally the password should be easy to remember but hard to guess. I show you how to generate strong passwords that are not easy to remember :). We'll use for this purpose /dev/urandom device, which generates random data. Suppose we want to generate 10 passwords, each 8 characters long. To achieve this we type:

$ cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -8 | head -10
lUrBzyuv
RuDq498i
mOzJMs4Y
s0lUpMZd
LmwuN6Sy
fubIOO6g
KKynsPs4
dFH4W0Ux
3JAbwJQD
PofhRhTS

The fold command breaks each line after n characters, so defines the length of the password, the head command shows first n lines so defines the number of passwords. The tr deletes (-d) all but specified (-c) characters. The idea comes from here.

No comments:

Post a Comment