Hey guys,
This is my situation.
I'm using the script to add a user account, however, i want the same details copied into the htdigest password list. the format is username:virtualservername:hashed/encrypted password.
This is the command :
sudo htdigest /etc/apache2/passwords VIRTUALSERVERNAME USERNAME
This are the exert from my script:
# Adding User (1st Step)
read -p "Enter username : " username
read -p "Enter password : " password
egrep "^$username" /etc/passwd >/dev/null
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
useradd -m -p $pass $username
[ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
# Adding webuser to apache password list
sudo htdigest /etc/apache2/passwords VIRTUALSERVERNAME $username <<-EOF
$password
$password
EOF
This doesn't work unfortunately.
I would still be asked to insert the password manually.
P/s: Removed the -s prefix for the password form as i want to see the password while typing it.