This command is used to generate the password in the crypt format:
mkpasswd
After you enter a command, the program asks for a password and then generates a string in crypt format.
If you are using an Apache Web server, you can also use HTPASSWD:
Htpasswd-nd User
It doesn't matter what the user name is, we are concerned with the password. This command will output a string in User:password format, and it will be OK to copy the password field directly.
If you have OpenSSL, you can use the OpenSSL command:
OpenSSL Passwd-crypt MyPassword
Replace the MyPassword in the above command with the password string you want to use.
There are other ways to enter commands directly in the command line, but the problem is that you can see the password in the PS command, and the password will be recorded in the Shell history.
But there is a solution to this problem: using a script, or a language interpreter.
For example, using Perl:
Perl-e "Print crypt (' Password ', ' sa ');"
Perl requires a cryptographic salt, such as the use of SA (salt refers to the random string used in encryption, with different salt to generate different encryption results).
Ruby also needs to encrypt salt:
Ruby-e ' print ' Password ". Crypt (" JU "); Print ("\ n"); '
PHP can also:
Php-r "Print (Crypt (' Password ', ' JU '). \ "\n\"); "
It is important to note that if you do not use a cryptographic salt (such as the Ju in the command above), the output string will not be in the Crypt encryption format, but in the MD5 encrypted format. So, the encryption salt is actually a necessary parameter.
Python needs to import the crypt library and use the encrypted salt:
Python-c ' Import crypt; Print Crypt.crypt ("password", "Fx") '
The crypto salt here is FX.
The database can also generate crypt passwords. For example, with MySQL:
echo "Select Encrypt (' Password ');" | Mysql
In addition, Tcl,ubuntu under the TRF, as well as LUA Lua-crypt plug-ins can also achieve the same purpose.
How to generate crypt encryption password under Linux