Hide Password on Unix Prompt
While we are dealing with the password. Security is very essential. There are no of ways to do the same. Storing the password's in a file and securing it by using tight access rights on the file to user's and groups.
If there are no of users using the shell script and using their own login credentials, Most effective way is to hide the password on the screen.
Below script depicts the similar use of the command :-
#!/bin/bash
#Usage
# Pass Username & Connectsting
#password will be asked at login time
if [ "$1" = "" ] || [ "$2" = "" ]; then
echo "Please pass Username and Database name to connect"
else
echo "Enter Pass"
read -s password
sqlplus -s "$1/$password@$2" << EOF
select sysdate from dual
/
EOF
fi
Script checks for the user name and database name in case user did not provide the same it will return the message and exit.
read -s password
will read the password from the user prompt however will not show the alphabets typed by the user and keep it secure since it is not available anywhere except with the user.
Wednesday, August 22, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment