Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to create passwords on the fly from a script.

Unfortunately I cannot use applications that utilize /dev/urandom because of the time it takes to create the password.

Are there other applications that I can use to create passwords on the fly?

share|improve this question
They all use /dev/urandom. Unless they use /dev/random, which is even slower. – Ignacio Vazquez-Abrams Apr 18 '11 at 22:43
You can't both have your cake and eat it. If you don't need the passwords to be random, use swordfish everywhere. If you do need the passwords to be random, /dev/urandom is as fast as it gets (unlike /dev/random which may block). – Gilles Apr 18 '11 at 23:12
How many passwords do you need in so short of a time that /dev/urandom is too slow? – Puddingfox Apr 18 '11 at 23:17
cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 12 | head -n 4 takes about .01 seconds... If you need something faster, you will probably need to write your own program. – Hyppy Apr 19 '11 at 1:15
More thought... perhaps your /dev/urandom is using /dev/random for some reason? Try cat /dev/urandom. If it's REALLY slow, and pauses when you don't move the mouse for a while, it's probably using /dev/random for some reason – Hyppy Apr 19 '11 at 3:28
up vote 4 down vote accepted

Apparently this answer worked:

cat /dev/urandom | tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?=' | fold -w 12 | head -n 4

... takes about .01 seconds.

share|improve this answer

The apg tool is kinda dated but still good for password generation. It supports sizing the passwords, password checking with dictionaries, generation of pronounceable or random passwords, has a built-in PRNG and /dev/random support and can generate various passwords on a bunch or on a shell script.


# apg -c random_seed 

Generate only one with no delimiter:

# apg -c random_seed -n 1 -d

Spell the generated passwords:

# apg -c random_seed -n 1 -d
aicWajbyRorp42863:~# apg -c random_seed -l
FrogQuev Foxtrot-romeo-oscar-golf-Quebec-uniform-echo-victor
cecNeiv1 charlie-echo-charlie-November-echo-india-victor-ONE
SkudVolt Sierra-kilo-uniform-delta-Victor-oscar-lima-tango
TowUlripab Tango-oscar-whiskey-Uniform-lima-romeo-india-papa-alfa-bravo
Bytquigpey Bravo-yankee-tango-quebec-uniform-india-golf-papa-echo-yankee
Doithneb Delta-oscar-india-tango-hotel-november-echo-bravo
share|improve this answer

You may try 'pwgen' (available in Ubuntu/Debian/Gentoo etc.)

Generate a 10 char password:

pwgen 10

Generate a more secure 10 char password:

pwgen -s 10

Generate a 'really' secure 10 char password:

pwgen -sy 10

Hope this helps, Cheers

share|improve this answer
pwgen uses /dev/urandom as well – James Apr 19 '11 at 1:51
mkpasswd -l 10
# will make a randon password with 10 chars - you may need to install it ...
share|improve this answer
mkpasswd uses /dev/urandom. – Ignacio Vazquez-Abrams Apr 18 '11 at 22:49
then make your own random ... like reading the clock then search some files ... sorry can't think of a faster way - one problem that you may have into the system is that you don't have enough entropy – silviud Apr 18 '11 at 22:51

The following generates a unique 8 lower and upper character password: openssl rand -base64 6

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.