2

I'm writing a DockerFile to build an image with apache2 and u2fval, and I need to create credentials for one user using apache2 digest. But the command:

htdigest -c /whatever/myfile.digest "realm" user

will always ask user for password, is there a way for me to give the command a password to use (Without prompting user etc...) ? Thanks.

2 Answers2

2

Don't add this command in Dockerfile directly. if you add password to Dockerfile then anyone can read.

just run this command to somewhere and create password file:

htdigest -c myfile.digest "realm" user

Now add this file to Dockerfile wherever you want to add using:

ADD myfile.digest /whatever/myfile.digest

OR

i would recommend you to not add this password file while image building. add while deploying that will be better when you want to change password.

OR

Still your requirement is this then refer these answer:

How do you htdigest 400 user accounts?

Scripting htdigest -c /path/to/file/$user $user $password in Bash

Community
  • 1
  • 1
pl_rock
  • 14,054
  • 3
  • 30
  • 33
0

just

echo "N" | htdigest ...

will give N as password

or use pexpect

https://pexpect.readthedocs.io/en/stable/

user2915097
  • 30,758
  • 6
  • 57
  • 59