4.5.1 Access control by user name and password

Use the htpasswd command and register the user name and password in the password file. You can define access permissions to the directory and files in the host for a registered user name. For details on how to use the htpasswd command, see (1) Registering the user name and password in the password file and changing the password.

Example: The <Cosminexus-installation-directory>\httpsd\htdocs\directory is accessible only to specific users.
Use the htpasswd command and register the user name and password beforehand in the password file (<Cosminexus-installation-directory>\httpsd\htdocs\.htpasswd). Set the following directives in the httpsd.conf file. If a user accesses the <Cosminexus-installation-directory>\httpsd\htdocs\, the Web server responds with the status code 401 Authorization Required, and the Web browser requests for the user name and the password:

<Directory "<Cosminexus-installation-directory>/httpsd/htdocs">
   AuthType Basic
   AuthName "realm 1"
   AuthUserFile "<Cosminexus-installation-directory>/httpsd/htdocs/.htpasswd"
   Require valid-user
</Directory>

[Figure]
Organization of this subsection
(1) Registering the user name and password in the password file and changing the password

(1) Registering the user name and password in the password file and changing the password

You can register and change the user name and password in the password file using the htpasswd command.

How to use the htpasswd command is described below:

(a) Format

htpasswd [-b][-c | -D] password-file-name user-name[password]

(b) Parameters
(c) Usage method

If you specify the password file name, the user name to be registered, or the user name for which the password is to be changed, and run the htpasswd, the input of respective password is requested. If you enter the password twice, including the confirmation of password entry, the user name and the password of that user are registered in the password file:

C:\>"<Cosminexus-installation-directory>\httpsd\bin\htpasswd.exe" .passwd userxx     ...1.
New password:                                                          ...2.
Re-type new password:                                                  ...3.
Updating password for userxxx                                          ...4.
C:\>

  1. Change the password of userxx
  2. Enter a new password
  3. Re-enter the new password
  4. End the registration of new password

When deleting the registration, start the htpasswd utility by specifying the -D option, the password file name, and the user name that is to be deleted.

C:\>"<Cosminexus-installation-directory>\httpsd\bin\htpasswd.exe" -D .passwd userxx  ...1.
Deleting passwd for userxx                                             ...2.
C:\>

  1. Delete registration of userxx
  2. Delete the registration of userxx and exit
(d) Note