htpasswdのパスワード方式

htpasswdのパスワード方式って何だっけ? という事で調べてみました

[hoge@... ]$ htpasswd
Usage:
        htpasswd [-cmdpsD] passwordfile username
        htpasswd -b[cmdpsD] passwordfile username password

        htpasswd -n[mdps] username
        htpasswd -nb[mdps] username password
 -c  Create a new file.
 -n  Don't update file; display results on stdout.
 -m  Force MD5 encryption of the password.
 -d  Force CRYPT encryption of the password (default).
 -p  Do not encrypt the password (plaintext).
 -s  Force SHA encryption of the password.
 -b  Use the password from the command line rather than prompting for it.
 -D  Delete the specified user.
On Windows, NetWare and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.

結果、いくつか指定できるようで、特定のものに決まってはいない。(デフォルトはCRYPT。平文も可)


「-p」オプションで平文に(警告されたけど..)

[hoge@... ]$ htpasswd -cp .htpasswd hoge
Warning: storing passwords as plain text might just not work on this platform.
New password:
Re-type new password:
Adding password for user hoge

[hoge@... ]$ cat .htpasswd
hoge:hogepass

様々な形式を試してみました

$ htpasswd -c .htpasswd user1	// default(CRYPT)
$ htpasswd -m .htpasswd user2	// MD5
$ htpasswd -s .htpasswd user3	// SHA
$ htpasswd -p .htpasswd user4	// no password

$ cat .htpasswd
user1:kFTZnBZFbadEc
user2:$apr1$O.Vw....$k/hgC.7.ANbuNp4N4QHs4.
user3:{SHA}cRDtpNCeBiql5KOQsKVyrA0sAiA=
user4:1234