function of the day

I love the simple solution and the open to glue something together that just works without learning to much that is after a few days lost again.

Maybe that is the reason I prefer to use linux and the ability to glue those nice single purpose tools with a | together.


I prefer NGINX over Apache, but most time installed the apache-utils to have the option to create a htpasswd file.

Now my own solution without the need of install the apache-utils on the system, create a function in your .bashrc as the following:

htpasswd() { PASS=$(openssl passwd -apr1); echo "$1:${PASS}" >> $2 ;}

now you are able to call htpasswd USERNAME HTPASSWDFILE to add new users to the htpasswd file and the password will be requested interactive - no trace in the history.

No error handling, no help is provided - but feel free to adopt this.