It seems you need to keep some secret in your script and it doesn't seems to be a right place for that.
Think about that: script needs to be readable by the user to be interpreted by bash, how would you prevent user from copying the script, removing any checks from it and executing this modified version?
You'd better use some external utility for password check, for example use gnome keyring as suggested by @desgua
Also, if you want user to input THEIR OWN password, you may try a trick with sudo, say you'll do it for tester username:
- change owner of a script to some other user (I'll call it admin in this example):
chown admin /path/to/script.sh
- make script accessible only by this user
chmod 700 /path/to/script.sh
give users that should run this script sudo rights to execute this script (you may limit their sudo rights to ONLY this script), to do so add something like this to
/etc/sudoers file (use visudo to edit this file):
tester ALL = (admin) /path/to/script.sh
now user tester could run
sudo -u admin /path/to/script.sh and will be asked for HIS OWN password by sudo. He won't be able to run other commands on the name of admin or read script content.