I would like to create a bash script where the user can select the username, password and confirm the password by entering it twice. If the passwords do not match the user's request, you must enter it again. If the passwords match, the script should create a password, but otherwise repeat the request until it is correct.
So far I have the code below, but I'm not sure if this is the right way to do this. Is there a problem with the following bash script?
read -p "Username: " username
read -s -p "Password: " password
echo
read -s -p "Password (again): " password2
while [ "$password" != "$password2" ];
do
echo
echo "Please try again"
read -s -p "Password: " password
echo
read -s -p "Password (again): " password2
done
passwordhash=`openssl passwd -1 $password`
source
share