10 ways to generate random passwords using Linux systems

Source: Internet
Author: User
Tags base64

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:

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

生成结果如下:

    1. 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:

    1. </dev/urandom TR-DC _a-z-a-z-0-9 |head-c${1:-32};echo

生成结果如下:

    1. Pdj0xwz7exd_qb5b27bwwsm1hrf3a7cj

3. Using the random function of OpenSSL

    1. OpenSSL Rand-base64 32

生成结果如下:

    1. ryjwqjltlayex3j7ncbir20h1k/0cnqlneunytscfko=

4. This method is similar to the previous Urandom, but it is reverse-working

    1. TR-CD ' [: alnum:] ' </dev/urandom | fold-w32 | Head-n1;echo

生成结果如下:

    1. Tpgudzf7sqtu4yyw2lvhmuqoziqi87

5. Use the string command to output a printable string from a file

    1. Strings/dev/urandom | Grep-o ' [[: Alnum:]] ' | Head-n 32 | Tr-d ' \ n '; Echo

生成结果如下:

    1. W4v1iqtkmq8sidd9jxdqnpg8hpmoz8

6. This is a simpler version of using Urandom

    1. </dev/urandom TR-DC _a-z-a-z-0-9 | Head-c32;echo

生成结果如下:

    1. Rmdlgspn_bm-izvfwz9bei0rf-jiy6gs

7. Use the very useful DD command

    1. DD if=/dev/urandom bs=1 count=2>/dev/null | base64-w 0 | rev | Cut-b 2-| rev

生成结果如下:

    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 ' [email protected]#$%qwertqwertasdfgasdfgzxcvbzxcvb ' | Head-c32; Echo

生成结果如下:

    1. Vtg3#tr4sagxg3z%##[email protected] $wdqF

9. If one of the above methods is used each time, the better way is 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 in your ~/.BASHRC file.

    1. RANDPW () { </dev/urandom tr-dc _a-z-a-z-0-9 | Head-c${1:-16};echo;}

生成结果如下:

    1. 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 in fact, if you use all the strings that it generates as passwords, that password is random enough.

    1. Date | Md5sum

生成结果如下:

    1. E0d057b46a9a78346cbd94b25e574e79-
    1. Date | Base64
生成结果如下:
    1. mjaxnow5tcawn+acicazmeaxpsdmmj/mnj/lm5sgmtc6mda6mzygq1nucg==
    1. Ifconfig | Md5sum

生成结果如下:

    1. 7c4243742aa515d45c12deca31428a95-

甚至你想生成一个核弹发射密码都可以,下面是一个生成长密码的例子;

    1. Ifconfig | Base64

生成结果如下:

  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=

10 ways to generate random passwords using Linux systems

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.