Search tutorial by keyword

How to generate random passwords from commands

Password is an important security feature for Linux and all other OS. It’s good to have the computer generate a random and complex password that is hard to break. In this post I will show you how a good password can be generated.

1) This method uses SHA to hash the date 

date +%s | sha256sum | base64 | head -c 32 ; echo

2) This command uses Linux built in feature which is present in /dev/random

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;

3) This is a unique method and you must have openssl installed before you use this method 

openssl rand -base64 32

4) This is a powerful example of bash and it works in reverse of the urandom function

tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1

5) This is a very different method that uses string command to generate a password

strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo

6) A more simpler version of urandom can be done by the following command

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6

7) “dd” command is also used to produce random password

dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev

8) Linux provides you the facility to create random password that can be typed with left hand only

</dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo ""

9) Randpw function can make every thing easier for you just by using it in any line

randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;}

10) Last but not the least the most easiest way to generate a password is by date command with combination of mdh5

date | md5sum

 

Last modified onLunes, 04 Mayo 2015 14:35
Michael Dudli

Cloud Specialist with more than 10 years experience in the Hosting Business.

Website: www.cloudserver24.com

Contact

Ventas

sales@cloudserver24.com

Soporte

support@cloudserver24.com