Rotten mud: Application of apache password generation tool htpasswd, apachehtpasswd

Source: Internet
Author: User

Rotten mud: Application of apache password generation tool htpasswd, apachehtpasswd

This article was sponsored by Xiuyi linfeng and first launched in the dark world.

1. Role and installation of htpasswd

2. Detailed description of the htpasswd command

3. htpasswd instance

4. Application of htpasswd

I. Role and installation of htpasswd

Htpasswd is an apache tool used to create and update text files that store user names and passwords. It is mainly used for http-based user authentication.

The installation of htpasswd is very simple. It is generated with the installation of apache. This is the same as the AB tool. If any of your shoes cannot be understood, you can view the article "Application of apache Performance Testing Tool AB.

If apache is installed using the yum method of RPM, the command is stored in the/usr/bin/directory as follows:

Which htpasswd

/Usr/bin/htpasswd

If apache is installed by source code, the command is stored in the bin directory of the apache installation directory, as follows:

/Usr/local/apache2/bin

The htpasswd command usage can be viewed through the help of htpasswd, as follows:

Htpasswd-h

Ii. Explanation of the htpasswd command

In the first part, we checked the help information of htpasswd. Now let's take a look at the parameters in the help information.

The help information of htpasswd is as follows:

Htpasswd-h

Htpasswd [-javaspsd] passwordfile username

Htpasswd-B [javaspsd] passwordfile username password

Htpasswd-n [mdps] username

Htpasswd-nb [mdps] username password

Description of parameters of the htpasswd Command Option:

-C: Create an encrypted file.

-N: If the encrypted file is not updated, only the user name and password encrypted by the htpasswd command are displayed on the screen.

-M by default, the htpassswd command uses the MD5 Algorithm to encrypt the password. This parameter can be left unspecified by default.

-D indicates that the htpassswd command uses the CRYPT algorithm to encrypt the password.

-S indicates that the htpassswd command uses the SHA algorithm to encrypt the password.

-P indicates that the htpassswd command does not encrypt the password, that is, the plaintext password.

-B indicates entering the user name and password in the htpassswd command line instead of entering the password as prompted.

-D Indicates deleting a specified user.

Iii. htpasswd instance

In step 2, we listed the htpasswd parameter descriptions. Now we will introduce how to use these parameters through instances.

3.1Use the htpasswd command to add a user

Use the htpasswd command to add a user. We can use the-B and-c parameters. As follows:

Htpasswd-bc ilannifile ilanniuser 123456

Cat ilannifile

Htpasswd-bc ilannifile ilanniuser 123456

Generate an ilannifile password file in the current directory, and add a user whose username is ilanniuser and password is 123456. MD5 encryption is used by default.

3.2Add a user to the original Password File

Add a new user to the original password file. We can use the-B parameter. As follows:

Htpasswd-B ilannifile ilannitwo 123456

Cat ilannifile

Htpasswd-B ilannifile ilannitwo 123456

In the ilannifile password file, add a new user named ilannitwo with a password of 123456.

Note: The-c parameter cannot be added at this time. Otherwise, it overwrites the original password file and creates a new password file.

3.3If the password file is not updated, only the encrypted user name and password are displayed.

If you want to update the password file and only display the encrypted user name and password, you can use the-n parameter. As follows:

Htpasswd-n ilannitwo

Note that the-n parameter must be followed by an existing user in the password file. To be honest, this parameter has little practical significance.

3.4Use the htpasswd command to delete the user name and password

To delete a user that already exists in the password file, we can use the-D parameter. As follows:

Htpasswd-D ilannifile ilannitwo

3.5Use the htpasswd command to change the User Password

To achieve this goal, we must first use the htpasswd command to delete a specified user, and then use htpasswd to create a user to change the password. As follows:

Iv. Application of htpasswd

Htpasswd can be integrated with nagios, SVN, nginx, apache, etc. We will not describe it here. We will introduce the integration and use of htpasswd with the above programs separately in the future.

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.