Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-09-2010, 04:13 AM   #1
Senior Member
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
Blog Entries: 6

Rep: Reputation: 51
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?
Old 02-09-2010, 04:36 AM   #2
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
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.
Old 02-09-2010, 04:41 AM   #3
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
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
Old 02-09-2010, 04:46 AM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 02-09-2010 at 05:10 AM.


access, read, script, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
openssl: using a protected password in a script robertmarkbram Linux - Security 3 01-20-2010 06:38 PM
make a file password protected sherimm Linux - Software 3 04-01-2009 05:09 AM
Password Protected compressed files script jedilost1 Linux - Newbie 15 11-25-2008 02:49 PM
Password protected Apache ne21 Linux - Software 5 07-30-2004 01:08 AM
password protected directories dsgdevil Linux - General 1 02-17-2003 12:02 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration