Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
2  
They all use /dev/urandom. Unless they use /dev/random, which is even slower. –  Ignacio Vazquez-Abrams Apr 18 '11 at 22:43
1  
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
4  
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
1  
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

5 Answers 5

up vote 1 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.

Examples:

# apg -c random_seed 
dordififId
riHegyipju
Noafrathvu
IchJinCet
utadwulb
ethFench

Generate only one with no delimiter:

# apg -c random_seed -n 1 -d
AkKijNayn

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
2  
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

 
discard

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.