Writings Photos Code Contact Resume
Generate random passwords under GNU/Linux...

You are here

Submitted by msameer on Fri, 10/02/2006 - 11:30pm

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 ;-)

Comments

Submitted by conceptor@eglug.org on Sat, 11/02/2006 - 3: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 - 10:44am

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 - 5: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 - 4: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 Fri, 01/02/2008 - 11:21pm

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

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

try it ?

Submitted by Sharki (not verified) on Mon, 03/03/2008 - 6: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 - 4: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!

Submitted by sadormd (not verified) on Fri, 02/09/2011 - 6:38am

As alternative there are a handy tool called apg (apt-get install apg). Or you can use a web-based one: OPG - opg.sysadmin.md

Add new comment

Subscribe to /  digg  bookmark