10 methods for generating random passwords using Linux

Source: Internet
Author: User

10 methods for generating random passwords using Linux

 

In general, it is confusing to generate passwords. If the complexity is insufficient, it will be insecure, it is too complex to press the keyboard to play the same character (but these characters are usually regular). You can also use the 1 password or keepass software to generate it, however, it seems that 1 password is charged. In this case, let's have fun using linux to generate random passwords;

A major advantage of Linux is that you can implement the same thing in hundreds of ways. For example, you can generate a random password in dozens of ways. This article describes ten methods to generate a random password.

1. Use the SHA algorithm to encrypt the date and output the first 32 characters:

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

The result is as follows:

 
 
  1. ZTNiMGM0NDI5OGZjMWMxNDlhZmJmNGM4 

2. Use embedded/dev/urandom and filter out characters that are not commonly used.. Here, only the first 32 characters of the output result are returned:

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

The result is as follows:

 
 
  1. pDj0Xwz7exD_Qb5B27BwWsM1hrF3a7cJ 

3. Use Random Functions of openssl

 
 
  1. openssl rand -base64 32 

The result is as follows:

 
 
  1. rYJWqJlTLAYeX3j7nCbir20h1k/0CnqLNEuNyTScfKo= 

4. This method is similar to the previous urandom.But it works reversely.

 
 
  1. tr -cd '[:alnum:]' < /dev/urandom | fold -w32 | head -n1;echo 

The result is as follows:

 
 
  1. tpgudzF7sqtU4yyW2LVhmUQOZIQi87 

5. Use the string commandWhich outputs printable strings from a file

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

The result is as follows:

 
 
  1. W4v1iQtkmQ8sIDd9jxDQNpg8HPMOZ8 

6. This is a simpler version of urandom.

 
 
  1. < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32;echo 

The result is as follows:

 
 
  1. rMDlGSPN_bm-IZVFWz9BEi0rF-jIy6gs 

7. Use a very useful dd command

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

The result is as follows:

 
 
  1. 9+0RUd4U3HmSdMlgD7j0sf/r09MZFDVBS28W+pO2WcA 

8. You can even generate a password that can be entered with only the left hand.

 
 
  1. </dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c32; echo 

The result is as follows:

 
 
  1. VTG3#TR4sAgXg3Z%##WZG4ZQ@GZ$wdqF 

9. If you use the above method every time, it is better to save it as a function. If this is done, you can use randpw to generate a random password at any time after the command is run for the first time. Maybe youYou can save it to your ~ /. Bashrc File

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

The result is as follows:

 
 
  1. vgBX8cNo950RiykZRpPYa4BvbAvZbY_x 

10. The last method to generate a random password is the simplest.It can also run under Windows with Cygwin installed. It can also be run in Mac OS X. I am sure someone will complain that the password generated in this method is not random by other methods. But in fact, if you use all the strings it generates as the password, the password is random enough.

 
 
  1. date | md5sum 

The result is as follows:

 
 
  1. e0d057b46a9a78346cbd94b25e574e79 - 
 
 
 
  1. date | base64 
The result is as follows:
 
 
  1. MjAxNOW5tCAwN+aciCAzMeaXpSDmmJ/mnJ/lm5sgMTc6MDA6MzYgQ1NUCg==  
 
 
  1. ifconfig | md5sum 

The result is as follows:

 
 
  1. 7c4243742aa515d45c12deca31428a95 - 

You can even generate a nuclear bomb launch password. The following is an example of a growth password;

 
 
  1. ifconfig | base64 

The result is as follows:

 
 
  1. ZW0xICAgICAgIExpbmsgZW5jYXA6RXRoZXJuZXQgIEhXYWRkciA3ODoyQjpDQjoyQjpCMDo5NCAg  
  2. CiAgICAgICAgICBpbmV0IGFkZHI6MTkyLjE2OC4zLjUgIEJjYXN0OjE5Mi4xNjguMy4yNTUgIE1h  
  3. c2s6MjU1LjI1NS4yNTUuMAogICAgICAgICAgaW5ldDYgYWRkcjogZmU4MDo6N2EyYjpjYmZmOmZl  
  4. MmI6YjA5NC82NCBTY29wZTpMaW5rCiAgICAgICAgICBVUCBCUk9BRENBU1QgUlVOTklORyBNVUxU  
  5. SUNBU1QgIE1UVToxNTAwICBNZXRyaWM6MQogICAgICAgICAgUlggcGFja2V0czoyMDY3NTY0IGVy  
  6. cm9yczowIGRyb3BwZWQ6MCBvdmVycnVuczowIGZyYW1lOjAKICAgICAgICAgIFRYIHBhY2tldHM6  
  7. ODg2NDUgZXJyb3JzOjAgZHJvcHBlZDowIG92ZXJydW5zOjAgY2FycmllcjowCiAgICAgICAgICBj  
  8. b2xsaXNpb25zOjAgdHhxdWV1ZWxlbjoxMDAwIAogICAgICAgICAgUlggYnl0ZXM6MjAzNDkzNTEx  
  9. ICgxOTQuMCBNaUIpICBUWCBieXRlczozMjUyNzUxNiAoMzEuMCBNaUIpCgpsbyAgICAgICAgTGlu  
  10. ayBlbmNhcDpMb2NhbCBMb29wYmFjayAgCiAgICAgICAgICBpbmV0IGFkZHI6MTI3LjAuMC4xICBN  
  11. YXNrOjI1NS4wLjAuMAogICAgICAgICAgaW5ldDYgYWRkcjogOjoxLzEyOCBTY29wZTpIb3N0CiAg  
  12. ICAgICAgICBVUCBMT09QQkFDSyBSVU5OSU5HICBNVFU6MTY0MzYgIE1ldHJpYzoxCiAgICAgICAg  
  13. ICBSWCBwYWNrZXRzOjU2OTkzMSBlcnJvcnM6MCBkcm9wcGVkOjAgb3ZlcnJ1bnM6MCBmcmFtZTow  
  14. CiAgICAgICAgICBUWCBwYWNrZXRzOjU2OTkzMSBlcnJvcnM6MCBkcm9wcGVkOjAgb3ZlcnJ1bnM6  
  15. MCBjYXJyaWVyOjAKICAgICAgICAgIGNvbGxpc2lvbnM6MCB0eHF1ZXVlbGVuOjAgCiAgICAgICAg  
  16. ICBSWCBieXRlczozMzEzMDcxOSAoMzEuNSBNaUIpICBUWCBieXRlczozMzEzMDcxOSAoMzEuNSBN  
  17. aUIpCgo= 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.