-   Linux - Newbie (
-   -   How to make script password protected? (

your_shadow03 02-09-2010 04:13 AM

How to make script password protected?
I have written a script named where it has password added. Now I don't want any user to see the content.What tool/utility can I preferrably use?

irmin 02-09-2010 04:36 AM

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.

sohail0399 02-09-2010 04:41 AM

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
cd shc-X.X/
make install

I use this command to encrypt

shc -f

it creates .x file

jschiwal 02-09-2010 04:46 AM

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 12:30 AM.