HOWTO: Generating Good Random Passwords With /dev/urandom

| No TrackBacks
Traditionally, I've relied on online JavaScript password generators to create my passwords.  I prefer extremely complicated ones, like sPtBf4CDuul9Wlol and H0SD9BHz4xHIah0h (at least 16-characters are preferred).  However, when I'm setting up a new system for myself, or configuring user accounts on a shared box at work, JavaScript password generators are slightly inconvenient if I don't have a web-browser handy.  Plus, if I need to generate multiple passwords for many users, it's unrealistic to use to a JavaScript password generator embedded in a web-browser.

Luckily, a colleague at work pointed out an easy way of generating good passwords using /dev/urandom on Linux:

head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c 16; echo

On HP-UX, run:

head -n 500 -c /dev/urandom | tr -dc a-z0-9A-Z | head -n 16 -c

Note you can change the "16" in the final call to head to get a different password length of your choice.


FOLLOWUP 2/7/09:

If you'd like to generate several random passwords using a shell/Bash script, see my post on HOWTO: Generating Many Good Random Passwords 'Automagically'.


FOLLOWUP 6/8/09:

David Douthitt at UNIX Administratosphere recently covered a great way to generate passwords using Perl. His method is especially useful on HP-UX and OpenVMS boxes. Thanks, David!


Wikipedia has a lot of good information on selecting a good password.  Password strength is an interesting problem, and different folks have different opinions with regards to what constitutes a "good" password.  Regardless, I suggest following a few key rules when creating a password:

  • Include numbers, symbols, upper and lowercase letters in passwords.
  • Password length should be around 12 to 14 characters.
  • Avoid any password based on repetition, dictionary words, letter or number sequences, usernames, relative or pet names, or biographical information (eg, dates, ID numbers, ancestors names or dates, ...).

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on October 26, 2008 7:03 PM.

HOWTO: Use MPlayer to Rip an MP3 Stream was the previous entry in this blog.

You Say Linksys I Say Tomato is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.