How to generate a strong password using the Linux command line
This article mainly introduces how to use the Linux command line to generate a high-strength password, the article is very detailed, has a certain reference value, interested friends must read it!
Use openssl to generate strong passwords
The rand method of openssl is used here, which generates a random character of 14 characters:
Openssl rand-base64 14
Use urandom to generate strong passwords
Here we will use the tr condition to filter the output of / dev/urandom to delete the unwanted characters and print out the 14-bit characters that appear.
< / dev/urandom tr-dc A-Za-z0-9 | head-c14; echo
Use pwgen to generate strong passwords
Pwgen is a random password that has no special meaning but can be spelled properly.
To install pwgen, run:
Sudo apt-get install pwgen
After installation, use the following command to generate a 14-bit random character:
Pwgen 14 1
You can also use the following markers:
The password generated by-c or-- capitalize contains at least one uppercase letter
Passwords generated by-An or-- no-capitalize do not contain uppercase letters
The password generated by-n or-- numerals contains at least one number
-0 or-- passwords generated by no-numerals do not contain numbers
The password generated by-y or-- symbols contains at least one special character
-s or-- secure generates a completely random password
Passwords generated by-B or-- ambiguous do not contain confusing characters (ambiguous characters)
-h or-- help output help information
-H or-- sha1=path/to/file [# seed] uses the sha1 hash value of the specified file as the random generator
-C outputs the generated password by column
-1 does not output the generated password by column
-v or-- no-vowels do not use any vowels to avoid accidentally generating annoying words
Use gpg to generate strong passwords
We can also use the gpg tool to generate a 14-character password:
Gpg-gen-random-armor 1 14
Other methods
Of course, there may be many ways to generate a strong password. For example, you can add the following bash shell method to the ~ / .bashrc file:
Genpasswd () {strings / dev/urandom | grep-o'[[: alnum:]]'| head-n 14 | tr-d'\ nkeeper; echo}
When you want to generate a high-strength random password, just run genpasswd.
The above is all the contents of the article "how to use the Linux command line to generate a strong password". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!