Linux generates random passwords

Source: Internet
Author: User
Tags base64

Often people generate passwords are confused, one is not enough complexity will be unsafe, enough complexity and can not manually hit the keyboard to play together characters (but usually these characters are regular),

Use 1password or keepass This software generation can also, but looks like 1password to charge, since so we play a fun to use Linux to generate random passwords to play it;
One of the great advantages of the Linux operating system is that you can use up to hundreds of ways to implement it for the same thing.

For example, you can generate random passwords in dozens of ways. This article describes 10 ways to generate a random password.




1. Use the SHA algorithm to encrypt the date and output the first 32 characters of the result: date +%s |sha256sum |base64 |head -c 32 ;echo& nbsp; The resulting result is as follows: Ztnimgm0ndi5ogzjmwmxndlhzmjmngm4 2. Use the inline/dev/urandom and filter out characters that are not used everyday. This also outputs only the first 32 characters of the result: < /dev/urandom tr -dc _a-z-a-z-0-9 |head -c${1:-32};echo The   results are as follows: pdj0xwz7exd_qb5b27bwwsm1hrf3a7cj 3, random function using OpenSSL openssl rand -base64 32   generated the results as follows: Ryjwqjltlayex3j7ncbir20h1k/0cnqlneunytscfko= 4. This method is similar to the previous urandom, but it is the reverse work of tr -cd  ' [: alnum:] '  < /dev/urandom | fold -w32  | head -n1;echo  generated the results as follows: Tpgudzf7sqtu4yyw2lvhmuqoziqi87 5. Using the string command, it outputs a printable string from a file strings /dev/urandom | grep -o  ' [[: Alnum:]] '  |  head -n 32 | tr -d  ' \ n '; echo  generated the results as follows: W4v1iqtkmq8sidd9jxdqnpg8hpmoz8  6. This is a simpler version of using Urandom < /dev/urandom tr -dc _a-z-a-z-0-9 | hThe ead -c32;echo  generates the following results: Rmdlgspn_bm-izvfwz9bei0rf-jiy6gs 7. Use the very useful DD command dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w The  0 | rev | cut -b 2- | rev  generates the following results: 9+0rud4u3hmsdmlgd7j0sf/ R09mzfdvbs28w+po2wca 8. You can even generate a password that can be entered with only the left hand </dev/urandom tr -dc  ' [email protected]#$% QWERTQWERTASDFGASDFGZXCVBZXCVB '  | head -c32; echo  generated the results as follows: Vtg3#tr4sagxg3z%##[email  protected] $wdqF  9. If you use one of these methods each time, it's better to save it as a function. If you do, you can use RANDPW at any time to generate a random password after you run the command for the first time. Maybe you can save it to your ~/.BASHRC file. RANDPW () { < /dev/urandom tr -dc _a-z-a-z-0-9 |  Head -c${1:-16};echo;}   generated the results as follows: Vgbx8cno950riykzrppya4bvbavzby_x 10. Finally, this method of generating random passwords is the simplest. It can also run under Windows with Cygwin installed. It can also be run under Mac OS x. I'm sure there will be complaints that this method generates a password that has no other method to be random. But actually if you use all the strings that it generates as passwords, then the password is random enough to date | md5sum  the resulting result: E0D057B46A9A78346CBD94B25e574e79 -   date | base64  generates the following results: mjaxnow5tcawn+acicazmeaxpsdmmj/mnj/ lm5sgmtc6mda6mzygq1nucg==   ifconfig | md5sum  generates the following results: 7c4243742aa515d45c12deca31428a95  -  even if you want to generate a nuclear launch code, here is an example of a growth password; The ifconfig | base64  generates the following results: ZW0XICAGICAGIEXPBMSGZW5JYXA6RXROZXJUZXQGIEHXYWRKCIA3ODOYQJPDQJOYQJPCMDO5NCAG   CIAGICAGICAGICBPBMV0IGFKZHI6MTKYLJE2OC4ZLJUGIEJJYXN0OJE5MI4XNJGUMY4YNTUGIE1H   C2s6mju1lji1ns4yntuumaogicagicagicagaw5lddygywrkcjogzmu4mdo6n2eyyjpjymzmomzl   Mmi6yja5nc82ncbty29wztpmaw5rciagicagicagicbvucbcuk9brenbu1qgulvotklorybnvuxu   Sunbu1qgie1uvtoxntawicbnzxryawm6mqogicagicagicagulggcgfja2v0czoymdy3nty0igvy   CM9YCZOWIGRYB3BWZWQ6MCBVDMVYCNVUCZOWIGZYYW1LOJAKICAGICAGICAGIFRYIHBHY2TLDHM6   ODG2NDUGZXJYB3JZOJAGZHJVCHBLZDOWIG92ZXJYDW5ZOJAGY2FYCMLLCJOWCIAGICAGICAGICBJ   B2xsaxnpb25zojagdhhxdwv1zwxlbjoxmdawiaogicagicagicagulggynl0zxm6mjazndkzntex   IcgxotqumcbnauipicbuwcbiexrlczozmjuYnzuxniaomzeumcbnauipcgpsbyagicagicagtglu   AYBLBMNHCDPMB2NHBCBMB29WYMFJAYAGCIAGICAGICAGICBPBMV0IGFKZHI6MTI3LJAUMC4XICBN   Yxnroji1ns4wljaumaogicagicagicagaw5lddygywrkcjogojoxlzeyocbty29wztpib3n0ciag   ICAGICAGICBVUCBMT09QQKFDSYBSVU5OSU5HICBNVFU6MTY0MZYGIE1LDHJPYZOXCIAGICAGICAG   Icbswcbwywnrzxrzoju2otkzmsblcnjvcnm6mcbkcm9wcgvkojagb3zlcnj1bnm6mcbmcmftztow   CIAGICAGICAGICBUWCBWYWNRZXRZOJU2OTKZMSBLCNJVCNM6MCBKCM9WCGVKOJAGB3ZLCNJ1BNM6   MCBJYXJYAWVYOJAKICAGICAGICAGIGNVBGXPC2LVBNM6MCB0EHF1ZXVLBGVUOJAGCIAGICAGICAG   ICBSWCBIEXRLCZOZMZEZMDCXOSAOMZEUNSBNAUIPICBUWCBIEXRLCZOZMZEZMDCXOSAOMZEUNSBN  aUIpCgo= 

  

For more information, please visit Li Hing Lee Blog

Linux generates random passwords

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.