Occasionally, I find myself logged into a system that does not have a random password application installed and do not want to go to the trouble of downloading one. Below is the easiest processes that I have found to generate a pretty random password from any Linux variant.
To begin, strait from the Linux man page:
/dev/random
When read, the /dev/random device will only return random bytes within the estimated number of bits of noise in the entropy pool. /dev/random should be suitable for uses that need very high quality randomness such as one-time pad or key generation. When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered.
/dev/urandom
A read from the /dev/urandom device will not block waiting for more entropy. As a result, if there is not sufficient entropy in the entropy pool, the returned values are theoretically vulnerable to a cryptographic attack on the algorithms used by the driver. Knowledge of how to do this is not available in the current non-classified literature, but it is theoretically possible that such an attack may exist. If this is a concern in your appli‐cation, use /dev/random instead.
So basically, using /dev/random results in the strongest and most random characters. Only downfall is the wait needed unless you have a lot of noise or specific hardware to accelerate the process.
* I tested a cut and paste from this page and some of the lines did not work correctly due to either the CSS or WordPress doing something weird with the ‘ and ` symbols. So if one of the strings do not work for you, try deleting the ‘ and adding it back in.
Creating random passwords which contains no special characters, is 10 characters long and displays 4
$ cat /dev/urandom| tr -dc 'a-zA-Z0-9' | fold -w 10| head -n 4 z4w7RENNIn ZOYg80cuQx Kgm6IrS5wc F741uiEXl6
Creating passwords which DO contain special characters, and is 12 characters long. The grep at the end might seem a little redundant, but depending on how short your character length is (using fold), urandom will result in stings with no special characters. Grep keeps that from happening here.
$ cat /dev/urandom| tr -dc 'a-zA-Z0-9-_!@#$%^&*()_+{}|:<>?='|fold -w 12| head -n 4| grep -i '[!@#$%^&*()_+{}|:<>?=]'
a(PYY5oid#2Z
>s#e)C5Kl=kc
63r)WBt9Y)^J
2_a5RLJV<CZH
Continue reading ‘Linux: Generating Strong Passwords Using random/urandom’
