I have following problem Im writing a script (in bash ) , where need to be written login & passwd for databas client .
Its need to in following form login passwd@dbhostname .
The problem is so anybody can read it so the passwd & login are visible and thats not very safety .
Can anybody advice me how to hide the details ?
Shall I save it to another file (where the access rights will be restricted ? ) or is there another choice ?
thanks
You can use md5hash
echo -n AytosPouRwtaeiEinaiMalakas | md5sum --text > /path/to/save/the/passwd
Then You read the input of the user
Give paswd:****************
if [ `echo -n $UserInput | md5sum --text` = `cat /path/to/saved/passwd` ]; then echo "Login correct";
else
echo "try again"; fi
You can download the sources of other programs that use the way you want to perform (like ftp in ubuntu (i dont know if it does exist in other OS) i think) and see how they do it.
If running from a cron file, you might consider to run the file from a userid and groupid that cannot be read or executed by other userids. Then, you can "hide" the content by simply making the script file non-readable by other users. You can also put the file in a directory that is not searchable nor readable by other userids.
This is an easy method used by many people to protect sensitive content in files.