Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created September 26, 2016 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save james2doyle/5493fe2c3dace6a9778cf96009fa7c57 to your computer and use it in GitHub Desktop.
Save james2doyle/5493fe2c3dace6a9778cf96009fa7c57 to your computer and use it in GitHub Desktop.
Create a password with openssl passwd without asking for a prompt

You can generate a password without a prompt by piping text into openssl and passing a new flag. For example:

echo "password" | openssl passwd -apr1 -stdin

This will echo to stdout. This way you can write a script or something instead of having to use the prompt to type in the password.

If you still wanted to append the output to the /etc/nginx/.htpasswd file, then you would do the following:

echo "password" | openssl passwd -apr1 -stdin >> /etc/nginx/.htpasswd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment