//View Tip #161
» Bash efficiency formula ;-)
» Manipulate Bash sockets using /dev/tcp
» Disable bash history
» Bash function to decompress archives
Similar Tips
» Find and replace with backup» Bash efficiency formula ;-)
» Manipulate Bash sockets using /dev/tcp
» Disable bash history
» Bash function to decompress archives
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
This is a simpler password generator.
Note that the 'tr' strips out everything except characters in the ranges (alphanumeric, mixed case and underscores). This is a nice approach as piping to head means the minimum number of bytes required to generate a password of appropriate length are taken from /dev/urandom vs other methods which take more than you should need but still have a chance of not having obtained enough random data to generate a password of the required length. You can change the parameter to head to get passwords of any length.
< /dev/urandom tr -dc A-Za-z0-9_ | head -c8
Note that the 'tr' strips out everything except characters in the ranges (alphanumeric, mixed case and underscores). This is a nice approach as piping to head means the minimum number of bytes required to generate a password of appropriate length are taken from /dev/urandom vs other methods which take more than you should need but still have a chance of not having obtained enough random data to generate a password of the required length. You can change the parameter to head to get passwords of any length.
Comments
Add your comment
Another way to do it:
dd if=/dev/urandom ibs=6 count=1 2>/dev/null | base64
dd if=/dev/urandom ibs=6 count=1 2>/dev/null | base64
Posted 2009-02-24 23:53:31
You can add special chars as well.
< /dev/urandom tr -dc 'A-Za-z0-9[=!=][=$=][=@=][=%=][=^=]' | head -c9 ; echo
< /dev/urandom tr -dc 'A-Za-z0-9[=!=][=$=][=@=][=%=][=^=]' | head -c9 ; echo
Posted 2009-06-04 15:31:56


< /dev/urandom tr -dc A-Za-z0-9_ | head -c8 ; echo