Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to generate crypt encrypted password in Linux

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about how to generate crypt encrypted passwords in Linux, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

We can use the mkpasswd command: this command is used to generate passwords in crypt format:

Mkpasswd

After entering the command, the program asks for a password and then generates a string in crypt format.

If you use an Apache Web server, you can also use htpasswd:

Htpasswd-nd user

It doesn't matter what the user name (user) is, we focus on the password. This command will output a string in user:password format and copy the password field directly to ok.

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 on the command line, but there is a problem with this: the password can be seen in the ps command, and the password is recorded in the shell history.

But there is a solution to this problem: use a script, or a language interpreter.

For example, using Perl:

Perl-e "print crypt ('password','sa');"

Perl needs an encryption salt, such as sa (salt refers to random strings used in encryption, and different salt can produce different encryption results).

Ruby also needs encrypted 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 encrypted salt (such as JU in the above command), the output string will not be in crypt encrypted format, but in MD5 encrypted format. Therefore, encryption salt is actually a necessary parameter.

Python needs to import the crypt library and use encrypted salts:

Python-c 'import crypt; print crypt.crypt ("password", "Fx")'

The encrypted salt here is Fx.

The database can also generate crypt passwords. For example, use MySQL:

Echo "select encrypt ('password');" | mysql

In addition, trf under Tcl,Ubuntu and the lua-crypt plug-in for Lua can also achieve the same goal.

The above is how to generate crypt encrypted passwords in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report