How to make script password protected?
I have written a script named scriptforhelp.sh where it has password added. Now I don't want any user to see the content.What tool/utility can I preferrably use?
Just set the owner of the file to you and remove reading permissions for other users:
chmod 700 file
or if other users are supposed to execute the file but should not read it:
chmod 711 file
Otherwise you can encrypt the file using gpg or similar.
In this regard this web site helps me:
I download the utility for linux from:
and install it commands are as follows:
tar -xzvf shc-X.X.tgz
I use this command to encrypt
shc -f script.sh
it creates .x file
For ssh access, use public keys instead of username/password. For mounting an smb share, use the "cred=" option in "sudo mount ..." commands where the file is only readable by effective user running mount.
If it is a password that the user of the script has access to, have the enter it in manually instead of putting it in a world readable script. E.G. don't use "mysql -u $USERNAME $DATABASE -p$PASSWORD" but instead use "mysql -u $USERNAME $DATABASE -p".
Or if you want to hide other users from seeing this users password, have the password read from the users HOME directory where other users can't read it.
Use polkit to allow a local session regular user to perform the action. (If there is a polkit authorization to do it)
Configure sudo to allow the user to perform that command, while requiring the users password, so the target password can remain a secret.
|All times are GMT -5. The time now is 05:29 AM.|