Generate htpasswd in Linux / UNIX Using Command Line / Terminal
Introduction
htpasswd is used to create and update the flat-files used to store usernames and password for basic authentication of HTTP users.
htpasswd encrypts passwords in different methods.It encrypts using either bcrypt, a version of MD5 modified for Apache, SHA1, or the system's crypt() routine. Files managed by htpasswd may contain a mixture of different encoding types of passwords; some user records may have bcrypt or MD5-encrypted passwords while others in the same file may have passwords encrypted with crypt().
Create a new password file
Creates a new file and stores a record in it for user naveen. The user is prompted for the password.
sudo htpasswd -c /opt/.htpasswd naveen
Change or update password
To add or modifies the password for user naveen, enter:
sudo htpasswd /opt/.htpasswd-users naveen
Adds or modifies the password for user naveen. The user is prompted for the password. The password will be encrypted using the modified Apache MD5 algorithm.