[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: automatic password generation



Daniel Martin writes:
> I'm just curious - how are you going to do this?  The best way I came up
> with was: PASS=`head --bytes=16 /dev/urandom | md5sum`

Clever, but it only produces hex.  I want all letters and digits.
This what I'm using:

  until [ `expr "$PASSWORD" : ".*"` -ge 8 ]
  do
    PASSWORD=`head -c 100 /dev/urandom | tr -dc '[:alnum:]' | head -c 8`
  done

> Oh and I suppose people can argue about /dev/random vs. /dev/urandom, but
> for your purposes /dev/urandom should be fine...

Right.  I just need unpredictable numbers, not random ones.

> ...also note that /dev/random might cause the process to freeze
> temporarily if the entropy pool has been depleted

Inconvenient during an unattended install.
-- 
John Hasler
john@dhh.gt.org (John Hasler)
Dancing Horse Hill
Elmwood, WI


Reply to: