how to generate apache passwords for basic authentication

apache accepts 4 password encryption types: plain text, crypt, sha1, and md5. these can be generated with the htpasswd command, or alternatively, with the openssl tool, as below.

htpasswd

crypt

+ htpasswd user password

md5

+ htpasswd -nbm user password

sha1

+ htpasswd -nbs user password

openssl

  • /bin/echo -n "user:" >>/etc/[nginx|httpd|apache]/passwd.file

then…

crypt

+ openssl passwd -crypt -salt date +%s password

md5

+ openssl passwd -apr1 -salt date +%s password

sha1

???