httpd htpasswd Command

Source: Internet
Author: User
Tags crypt md5 md5 encryption

Hrf:https://www.cnblogs.com/f-ck-need-u/p/8413490.html

HTPASSWD is used to generate a password based on Web user authentication for a specified user, provided by the Httpd-tools package. Supports 3 encryption algorithms: MD5, Sha, and the Crypt () function on the system, which defaults to MD5 when no algorithm is specified.

HTPASSWD [-c] [m] [d] passwdfile username
htpasswd-b [-c] [m |-d |-P |-S] [-d] passwdfile username Password
htpasswd-n [m |-d |-S |-p] username
htpasswd-nb [-M |-d |-S |-p] Username password
option Description:
passwdfile: A user password file that contains the user name and its password. If the "-C" option is used, the file is created or overwritten. You must specify the Passwdfile parameter when you do not use the "-n" option.
Username: Creates a password for the specified user name. If the user record already exists, it is updated. -
c: Create user password file Passwdfile, overwriting existing files if the file already exists. Cannot be used with "-N". -
N: Outputs the results in standard output instead of writing them to the user's password file. This option ignores the user password file passwdfile parameter. cannot be used with the "-C" option. -
m: Use the MD5 encryption algorithm. Default. -
D: It is not safe to use the crypt () function to compute the password.
-S: Use the SHA encryption algorithm. Safety.
-P: Force unencrypted password, keep plaintext state, unsafe.
-B: Force bcrypt encryption password, very safe.
-D: Deletes the specified user and password from the user's password file.
-B: Use batch mode, or Non-interactive mode, to pass plaintext passwords directly to the encryption.
Password: Specifies the plaintext password to enter. Can only be used in batch mode, that is, with "-B".

For example:

(1). Use the "-n" option to output the results directly to the standard output without creating a passwdfile.

[Root@xuexi ~]# htpasswd-n Jim
New password: 
re-type new password: 
Jim:zkhud9tzigucy

(2). Pass a password directly using batch mode.

[Root@xuexi ~]# htpasswd-nb Jim 123456; HTPASSWD-NB Jim 123456
Jim:r.bf8rvw56boa

JIM:XXONGOS8NN3LQ

The password was found to be completely random.

(3). Create user password file passwdfile.

[Root@xuexi ~]# HTPASSWD-CB bobfile Bob 123456
[Root@xuexi ~]# cat Bobfile 
BOB:FVUXZB3KCNDPK

(4). Deletes a user in the user file.

[Root@xuexi ~]# htpasswd-d bobfile Bob

(5). Use the SHA and MD5 encryption algorithms to calculate passwords.

[Root@xuexi ~]# htpasswd-mb bobfile Bob 123456
[Root@xuexi ~]# cat bobfile 
Bob: $apr 1$bllkodft$ Gumeb8hxngoaschs1sbgq0
[Root@xuexi ~]# htpasswd-sb bobfile Bob 123456 
[Root@xuexi ~]# cat Bobfile  
Bob:{ sha}feqncco3yq9h5zugld3czjt4lbs=

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.