Vagrant shell provisioning phpPgAdmin password

221 views Asked by At

How would I get my Vagrant shell script to supply the password when creating a user while provisioning phpPgAdmin?

ie. when I supply this command sudo htpasswd -c /etc/phppgadmin/.htpasswd vagrant it prompts for a password for the vagrant user so I can login to phpPgAdmin. How can I script this into my shell provisioning script that goes with my Vagrantfile?

2

There are 2 answers

1
Konstantin On BEST ANSWER

First, you need to force htpasswd to read passwords from stdin. It can be done by supplying -i switch.

Second, you need to pass a string into htpasswd stdin. This can be achieved in numerous ways. For example you can redirect stdout of echo into stdin of htpasswd.

So resulting command would look like this

echo "123456" | htpasswd -i -c /etc/phppgadmin/.htpasswd vagrant
0
Nobu On

With Apache 2.2, while -i was introduced on 2.4.4, the below command would work:

htpasswd -bc /etc/phppgadmin/.htpasswd vagrant password