How to generate random passwords with Shell script
This article mainly shows you "Shell script how to generate random passwords", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "Shell scripts how to generate random passwords" this article.
Generate random passwords (urandom version)
#! / bin/bash # Author: Jacob # / dev/urandom file is a Linux built-in random device file # cat / dev/urandom can see the contents, ctrl+c quit to view # after viewing the contents of the file, I found that the content is a little too random, including a lot of special symbols The password we need does not want to use these symbols # tr-dc'_ A-Za-z0-9'# this command can delete other characters from the random file, leaving only uppercase and lowercase letters, numbers and underscores, but there is still too much content # We can continue to pipe the optimized content to the head command Show only the first 10 bytes in a large amount of data # notice that An is preceded by an underscore tr-dc'_ A-Za-z0-9'
Generate random passwords (string intercepted version)
#! / bin/bash # Author: Jacob (Jacob) # set the variable key to store all the possibilities of the password (password library). If you need other characters, please add other password characters yourself # use the $# statistics password library length key= "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" num=$ {# key} # set the initial password to empty pass='' # loop 8 times Generate 8 random passwords # each time is the remainder of the length of the password base, ensuring that the extracted password characters do not exceed the length of the password base # extract one random password each cycle, and append the random password to the last for i in {1.. 8} do index=$ [RANDOM%num] pass=$pass$ {key:$index:1} done echo $pass of the pass variable
Generate a random password (UUID version, hexadecimal password)
#! / bin/bash uuidgen 4. Generate random passwords (process ID version, digital passwords) #! / bin/bash echo $$above is all the content of the article "how Shell scripts generate random passwords". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!