.htpasswd explained

.htpasswd is a flat-file used to store usernames and password for basic authentication on an Apache HTTP Server. The name of the file is given in the .htaccess configuration, and can be anything, although ".htpasswd" is the canonical name. The file name starts with a dot, because most Unix-like operating systems consider any file that begins with a dot to be hidden.[1] The htpasswd command is used to manage .htpasswd file entries.[2]

History

htpasswd was first added in the NCSA HTTPd server,[3] which is the predecessor to Apache.[4] The hash historically used "UNIX crypt" style with MD5 or SHA1 as common alternatives.[5] In Apache 2.4, the bcrypt algorithm was added.

Usage

The file consists of lines, with each line containing a username, followed by a colon, followed by a string containing the hashed password optionally prepended by an algorithm specifier ("$2y$", "$apr1$" or "") and/or salt.[6] [7] Athelstan:RLjXiyxx56D9s Mama:RLMzFazUFPVRE Papa:RL8wKTlBoVLKk

Resources available from the Apache HTTP Server can be restricted to just the users listed in the files created by htpasswd. The .htpasswd file can be used to protect the entire directory it is placed in, as well as particular files.[8]

Security issues

The only algorithm accepted by htpasswd that is still considered secure by today's standards is bcrypt,[9] and many formats do not use salting making it vulnerable to dictionary attacks. The crypt algorithm only uses the first 8 characters of any given password, discarding any past that.

See also

External links

Notes and References

  1. Web site: 2023-05-15 . Understanding Hidden Files and Folders in Your Home Directory – TecAdmin . 2024-02-08 . en-US.
  2. Web site: David . Jackson . July 30, 2023 . Mastering Htpasswd Command in Linux . Linux TLDR.
  3. Web site: NCSA httpd AuthUserFile . 2024-02-08 . www6.uniovi.es.
  4. Web site: About the Apache HTTP Server Project - The Apache HTTP Server Project . 2024-02-08 . httpd.apache.org.
  5. Web site: htpasswd - Manage user files for basic authentication . 2013-11-30.
  6. Web site: Password Formats - Apache HTTP Server Version 2.4 . 2024-02-08 . Apache.
  7. Web site: 2023-12-20 . HTTP authentication - HTTP MDN . 2024-02-08 . developer.mozilla.org . en-US.
  8. Web site: Services . Chameleon Web . 2014-03-24 . Password Protect File or Folder using .htaccess Chameleon Web Services . 2024-02-08 . en-GB.
  9. Web site: htpasswd file generator . 2024-02-08 . aspirine.org.