Unable to update the extServicePasswd file using htpasswd utility

21 views Asked by At

I am unable to update the extServicePasswd file using the 'htpasswd' utility

I deployed HTTPD on kubernetes using the "bullseye" tag.

The user details in my httpd.conf is as below:

User www-data
Group www-data

If I update this user and the group to 'root/root', the pod doesn't come up

All the files get mounted using the 'root' user.

I deployed the .extServicePasswd file as a configmap and if a new user credential is to be added, I do the below using shell script:

kubectl cp $CURRENT_POD:/usr/local/apache2/conf/custom/htpasswd/.extServicePasswd ./.extServicePasswd
echo "$USER_NAME:$(openssl passwd -apr1 $PASSWD)" >> .extServicePasswd
kubectl create configmap httpd-dummy-extservicepasswd --from-file=.extServicePasswd -o yaml --dry-run | kubectl replace -f -
kubectl rollout restart deployment $DEPLOYMENT

Here is have a duplicate check. The file is updated only when the user is a new user.

I have to write these multiple lines in the shell script because when I run the ./htpasswd utility, it gives me the below error:

/htpasswd -mb /usr/local/apache2/conf/custom/htpasswd/.extServicePasswd test1 test1

./htpasswd: cannot open file /usr/local/apache2/htpasswd/.extServicePasswd for read/write access.

Is there a way I can update the file using the htpasswd utility itself, instead of the achieving the same with multiple lines in shell script?

Please let me know if any more details are required.

0

There are 0 answers