Hi community,
I am rather new to bash, so i apologize in advance for my ignorance. I've created a simple bit of code that will prompt for a password before continuing in the script. The script works simply by reading a hash from the hash file (for the sake of the example, i've made it on the desktop) and checking it with the hash of the entered password. I want to augment the script to ask for a username and password, and to have the ability to work with multiple usernames (so that what the script will then do can differ with usernames), but i've found that i simply don't have the skills to do it. Any help would be greatly appreciated. Thank you so much! What I have so far is below:
Code:
#!/bin/bash
#
# Password_Protection.sh
#
theHash=`cat ~/Desktop/Hash.txt`
tries=2
num=$tries
read -sp "Type your password " enteredPass;
enteredHash=`echo "$enteredPass\\c" | openssl sha1 | cut -c9-`
if [ $enteredHash != $theHash ]; then
while [ $enteredHash != $theHash ]
do
read -sp "
incorrect, try again (try $tries) " enteredPass;
enteredHash=`echo "$enteredPass\\c" | openssl sha1 | cut -c9-`
tries=$(($num+1))
num=$tries
done
fi
echo "
__ __ ___ _ __ ___ ___ ___ ___
| |__| | / _] | / ]/ \| | | / _]
| | | |/ [_| | / /| | _ _ |/ [_
| | | | _] |___ / / | O | \_/ | _]
| | [_| / \_| | | | [_
\ /| | \ | | | | |
\_/\_/ |_____|_____|\____|\___/|___|___|_____|"
#
# code here...
#