LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-30-2011, 02:33 PM   #1
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Rep: Reputation: 17
How to set password protected of the script


Hi,
I have written a shell script in unix for my personal use. Now I want to make it only execute and not to read/write. Can anybody help me how to set password protect/encript my script.
If any one type vi script.sh, it should ask password, if password match then open an script. otherwise message should say deny.
I have vi editior ony not vim.

Thanks,
 
Old 12-30-2011, 03:09 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi deepak_message,

Well I am not aware of any tool or a way by which you can password protect a file in linux. However, you can play around with file system rights to restrict the access.

You can chown that file and then change the permission to 700 and that should be it. Remember that root user will be an exception in this case as root can do whatever he wants to do :-)

Commands for your reference:

Code:
chown your_username:your_personalgroup filename
Code:
chmod 700 filename
 
Old 12-30-2011, 03:11 PM   #3
droyden
Member
 
Registered: Feb 2007
Location: UK
Posts: 150

Rep: Reputation: 19
Bash, or whatever shell is interpreting the script needs to be able to read it so that it can execute it.
 
Old 12-30-2011, 03:24 PM   #4
scorpioz22
LQ Newbie
 
Registered: Apr 2009
Posts: 9

Rep: Reputation: 2
it should be chmod 711 if you want others to be able to execute the script but not able to read/write to it.
Code:
$ ls -l testscript.sh
-rwx--x--x 1 user user 0 Dec 30 13:23 testscript.sh
 
Old 12-30-2011, 03:28 PM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Yes, scorpioz22 is right it should be 711 if you want others to be able to execute that script. Sorry I didn't look at the part where you said that you want others to execute. Another way to make others to execute that script is setting up uid for that particular file so that other users will be able to run that file as if they are running using your user account.
 
Old 12-30-2011, 04:02 PM   #6
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
Thanks for your valuable time!!!

But I am looking when try todo #vi scritp.sh , it should ask password. if type wrong password , can't use the script using vi mode. they can read using cat. but can't edit.
 
Old 12-30-2011, 04:46 PM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Now I want to make it only execute and not to read/write. Can anybody help me how to set password protect/encript my script.
You can use shc to compile your script into a binary executable, so it cannot be read.
If there is no package for your distro, you can get the sources from here.

Regards
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Set Up A Web-Based Enterprise Password Manager Protected By Two-Factor Authentication LXer Syndicated Linux News 0 07-08-2011 08:20 AM
How to make script password protected? your_shadow03 Linux - Newbie 3 02-09-2010 04:46 AM
openssl: using a protected password in a script robertmarkbram Linux - Security 3 01-20-2010 06:38 PM
Password Protected compressed files script jedilost1 Linux - Newbie 15 11-25-2008 02:49 PM
How to set password from script? ssy68 Linux - Newbie 2 02-20-2008 04:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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