The htpasswd command can be used to create, reset, and view a users password.
Let's say your admin.conf file contains the following directive. In this example, the admin password file will need to be located at /opt/IBMIHS/conf/admin.passwd.
The htpasswd command with the -c option is used to create a file that will contain users htpasswd. A single admin.passwd file can contain multiple users htpasswd.. You will be prompted to provide the users password.
~]$ <web server root>/bin/htpasswd -c /opt/IBMIHS/conf/admin.passwd john.doe New password: Re-type new password: Adding password for user john.doe
The -B option can be used to create an encrypted, hashed password.
<web server root>/bin/htpasswd -B -c /opt/IBMIHS/conf/admin.passwd john.doe
The -b (batch mode) option can be used to include the password on the command line, but this is not ideal, as this exposes the password to the ps command and history
~]# <web_server_root>/bin/htpasswd -b /opt/IBMIHS/conf/admin.passwd john.doe itsasecret Adding password for user john.doe
Now, the admin.passwd file should exist.
-rw-r--r--. 1 root root 54 Mar 20 21:54 admin.passwd
The -v (verify) option can be used to ensure the users password is correct.
~]# <web_server_root>/bin/htpasswd -v /opt/IBMIHS/conf/admin.passwd john.doe Enter password: Password for user john.doe correct.
The -b (batch mode) option can be used to include the password on the command line.
<web_server_root>/bin/htpasswd -b -v /opt/IBMIHS/conf/admin.passwd john.doe
Or the -b option can be included to use the password on the command line.
~]# <web_server_root>/bin/htpasswd -vb /opt/IBMIHS/conf/admin.passwd john.doe itsasecret Password for user john.doe correct.