Htdigest is a command-line tool that is built into the Apache web server. It is used to create and manage user authentication files for HTTP Digest authentication. HTTP Digest authentication is a method of authentication that is used by web servers to authenticate users before allowing them access to protected resources.
Overview
Htdigest is used to create and manage user authentication files for HTTP Digest authentication. The authentication files contain usernames and password hashes, which are used by the web server to authenticate users. Htdigest can be used to create new authentication files, add new users to existing authentication files, and change the passwords of existing users.
The basic syntax of the htdigest command is as follows:
htdigest [-c] passwordfile realm username
Here, passwordfile
is the name of the authentication file, realm
is the authentication realm, and username
is the username to be added or modified. The -c
option is used to create a new authentication file.
For example, to create a new authentication file called users.digest
with a realm of MyRealm
and a user named john
, you would use the following command:
htdigest -c users.digest MyRealm john
This will prompt you to enter a password for the user john
, which will be added to the users.digest
file.
To add a new user to an existing authentication file, you would use the following command:
htdigest passwordfile realm username
For example, to add a user named jane
to the users.digest
file with a realm of MyRealm
, you would use the following command:
htdigest users.digest MyRealm jane
This will prompt you to enter a password for the user jane
, which will be added to the users.digest
file.
To change the password of an existing user, you would use the following command:
htdigest passwordfile realm username
For example, to change the password of the user john
in the users.digest
file with a realm of MyRealm
, you would use the following command:
htdigest users.digest MyRealm john
This will prompt you to enter a new password for the user john
, which will replace the existing password in the users.digest
file.
Options
The following options are available for the htdigest command:
Option | Description |
---|---|
-c | Create a new authentication file. |
-h | Display help information. |
Troubleshooting tips
If you are having issues with HTTP Digest authentication, there are a few things you can check:
- Make sure that the authentication file exists and is readable by the web server.
- Make sure that the realm specified in the authentication file matches the realm specified in the web server configuration.
- Make sure that the usernames and passwords in the authentication file are correct.
Notes
- Htdigest is only one part of the HTTP Digest authentication process. You will also need to configure your web server to use HTTP Digest authentication.
- Htdigest should not be used to store plaintext passwords. Instead, it stores password hashes using the MD5 algorithm.