Writings Photos Code Contact Resume Me
Generate random passwords under GNU/Linux...
Submitted by msameer on Sat, 11/02/2006 - 1:30am

Well, I want to generate random passwords for people I give subdomains.

Since creating the subdomain involves a lot of steps, I decided to automate it a bit.

And since I only install the most needed things on the server, I decided to create a small script to generate the random password for me as I don't feel like installing a password generator.

dd if=/dev/random count=10 bs=1 | hexdump  | cut -d \  -f 2-| head -n 1 | tr -d " "

Now the only 2 problems with the above script are:
1) No upper case letters.
2) No special characters.

I don't really think that the above problems are fatal since the user will change the password after that to something stupid, Why ? Because users are idiots, They are not as smart as me ;-)

Syndicate content  digg  bookmark

Submitted by conceptor@eglug.org on Sat, 11/02/2006 - 5:24am.

you can limit how man uppercase characters and how many spacial characters needed on your passwd

$ makepasswd --char=10

Submitted by msameer on Sat, 11/02/2006 - 12:44pm.

I don't want to install additional things.

For the sake of learning, I'll have a look at its source code to see how it's done ;-)

Submitted by mrdvt92 (not verified) on Sat, 22/07/2006 - 7:16am.

Try somthing like this and you can pick what chars you want by editing the sed.

dd if=/dev/urandom count=200 bs=1 2>/dev/null|tr "\n" " "|sed 's/[^a-zA-Z0-9]//g'|cut -c-16

Submitted by Anonymous (not verified) on Sat, 05/01/2008 - 6:07pm.

Here is what I came up with:

head -c 200 /dev/urandom | tr -cd '[:graph:]' | head -c 8

Submitted by Anonymous (not verified) on Sat, 02/02/2008 - 1:21am.

Why head -c 200 /dev/urandom
instead of simply cat /dev/urandom?

Submitted by msameer on Sat, 02/02/2008 - 4:53am.

try it ?

Submitted by Sharki (not verified) on Mon, 03/03/2008 - 8:50pm.

Use md5sum for better passwords:


dd if=/dev/urandom count=128 bs=1 2>&1 | md5sum | cut -b-10

Note '2>&1', this makes sure dd's stderr output is piped to md5sum, instead of your terminal.

Submitted by Eduardo Ivanec (not verified) on Thu, 18/12/2008 - 6:49pm.

I use:

head /dev/urandom | uuencode -m -

It depends on uuencode, obviously, but usually it's installed by default. Advantages over other methods: complete uppercase and lowercase alphabet, digits and some symbols (+, /).

Regards!

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <s> <li> <ol> <u> <ul> <br> <br />
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text. URLs will automatically be converted to links.
  • Lines and paragraphs break automatically.
  • You may write mixed Arabic and English freely, line direction will be computed automaticaly

More information about formatting options