Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to encrypt password using htpasswd.lens #812

Open
nsandhu-godaddy opened this issue May 3, 2023 · 1 comment
Open

how to encrypt password using htpasswd.lens #812

nsandhu-godaddy opened this issue May 3, 2023 · 1 comment

Comments

@nsandhu-godaddy
Copy link

It seems that when setting the password using the htpasswd.lens, it gets saved as plain text. Is it possible to save in one of the encrypted formats supported by htpasswd.

set username password
@georgehansper
Copy link
Member

Generating encryption hashes is outside the scope of what augeas is designed to do

Having said that, it is possible to use augeas to insert or update an existing password-hash hash into a file.
ie instead of supplying augeas with a password to encrypt, it is possible to generate the password-hash outside of augeas, and use augeas to update the htpasswd file

Example:

PWHASH="$( htpasswd -nb -5 user001 mysecret | sed -e 's/user101://' )"
augtool --noload <<EOF
load-file /etc/httpd/htpasswd
set /files/etc/httpd/htpasswd/webuser ${PWHASH}
save
EOF

which would set the password for the user "webuser" to the being "mysecret"
If the file /etc/httpd/htpasswd does not exist, it will be created, along with the user "webuser"

In the above example, the shell is substituting the variable ${PWHASH}
augtool only sees the resulting hash, and has no part in generating it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants