TIPS: generate a crypt password in Linux

Source: Internet
Author: User
Article Title: Tips: generate a crypt password in Linux. Linux is a technology channel of the IT lab in China. It includes desktop applications, Linux system management, kernel research, embedded systems, open source, and other basic categories. When we use the Red Hat Kickstart script or useradd or other methods to write things, the crypt command is often used to encrypt the generated password format. Is there any other way to generate a password in this format? In fact, there are many methods.
We can use the mkpasswd command: this command is used to generate a password in crypt format:
After mkpasswd enters the command, the program requires a password and generates a crypt string.
If you use an Apache Web server, you can also use htpasswd:
Htpasswd-nd the user name (user) does not matter. We are concerned with the password. This command will output a user: password string, directly copy the password field and it will be OK.
With OpenSSL, you can use the openssl command:
Openssl passwd-crypt myPassword replaces the myPassword in the above command with the password string you want to use.
There are other ways to directly input commands in the command line. However, there is a problem with this method, that is, the password can be seen in the ps command, the password is recorded in the shell history.
However, there is a solution to this problem: Use a script or a language interpreter.
For example, use Perl:
Perl-e "print crypt ('Password', 'sa ');" Perl requires an encryption salt. For example, sa (salt indicates the random string used in encryption, different salts can generate different encryption results ).
Ruby also needs encryption salt:
Ruby-e 'print "password". crypt ("JU"); print ("\ n"); 'php can also:
Php-r "print (crypt ('Password', 'ju '). \ "\ n \"); "note that if encryption salt (such as JU in the preceding command) is not used, the output string is not in crypt encryption format, it is in the MD5 encryption format. Therefore, encrypted salt is a required parameter.
Python needs to import the crypt library and use the encryption salt:
Python-c 'import crypt; print crypt. crypt ("password", "Fx") 'the encryption salt here is Fx.
The database can also generate a crypt password. For example, MySQL:
Echo "select encrypt ('Password');" | mysql In addition, trf in Tcl, Ubuntu, and Lua-crypt plug-ins can also achieve the same purpose.
Please add other methods!

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.