Shami's Blog

Sysadmin, Because Even Developers Need Heroes

Perl One-liner To Generate htpasswd Passwords

2014-12-29

Update: An easier way to do it that doesn’t require you to install anything special (Works with nginx)

openssl passwd -apr1

Instead of having to install Apache or use an untrusted website just to generate the required password, you can use the following perl one liner

perl -e 'chomp($password=<>);chomp($salt=`tr -dc A-Za-z0-9 </dev/urandom | head -c 1024`); print crypt($password,$salt)."\n";'

About Me

Dev gone Ops gone DevOps. Any views expressed on this blog are mine alone and do not necessarily reflect the views of my employer.

twitter linkedin