Generate Random Passwords from the Command Line

The most secure passwords used, are those that are randomly generated. From the command line, you can randomize potential passwords in multiple ways.

First method uses openssl, in the terminal type:

openssl rand -base64 6

The output of this command will be random, and as an example look like: cG/ah3+9

Adjustments to the length of the password can be done by changing the number on the end of the string. If abnormal characters are not wanted like ^ and *, generation can be done via hex too:

openssl rand -hex 4

For more random options, pipe the randomized output of openssl through md5 and trim the md5 hash of the randomized output down to a set number of characters:

openssl rand -base64 8 |md5 |head -c8;echo

Other options are to take random input from other commands, such as date, and trim 8 characters from the current dates md5 hash:

date |md5 | head -c8; echo

Or even ping:

ping -c 1 |md5 | head -c8; echo

Using the md5 method, the output of any command, or file, can be used to create a secure password.

Tagged with: , , , , ,
Posted in Macintosh

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your email address to follow this site and receive notifications of new posts by email.

Join 197 other subscribers
wordpress com stats plugin
%d bloggers like this: