encrypt stored passwords

This commit is contained in:
Matthew Saunders Brown 2023-03-30 14:57:56 -07:00
parent c463be70a2
commit b150d01b70
2 changed files with 17 additions and 4 deletions

View File

@ -79,10 +79,11 @@ if [[ ! -f "/home/$username/.profile" ]]; then
fi fi
if [[ -n $write ]]; then if [[ -n $write ]]; then
vhost::set-opensslpass
encryptedpass=`echo -n "$password" | openssl aes-256-cbc -a -salt -pass pass:$opensslpass -pbkdf2`
userpasswdinfo="$username:$encryptedpass:$uid:$uid::/home/$username:/bin/bash"
if [[ ! -f "/home/$username/.passwd" ]]; then if [[ ! -f "/home/$username/.passwd" ]]; then
touch /home/$username/.passwd install -o $username -g $username -m 640 /dev/null /home/$username/.passwd
chmod 640 /home/$username/.passwd echo "$userpasswdinfo" > /home/$username/.passwd
chown $username:$username /home/$username/.passwd
echo "$newusers" > /home/$username/.passwd
fi fi
fi fi

View File

@ -29,6 +29,18 @@ function vhost::set-phpVersion () {
} }
function vhost::set-opensslpass () {
if [[ -f "/root/.vhost.ini" ]]; then
opensslpass=`grep -E '^opensslpass\s?=' /root/.vhost.ini | cut -d = -f 2 | tr -d ' '`
else
install --owner=root --group=root --mode=640 /dev/null /root/.vhost.ini
opensslpass=`/usr/bin/pwgen 16 1`
echo "opensslpass = $opensslpass" >> /root/.vhost.ini
fi
}
# crude but good enough domain name format validation # crude but good enough domain name format validation
function vhost::validate_domain () { function vhost::validate_domain () {
local my_domain=$1 local my_domain=$1