The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Microsoft Security Advisory (917021): Description of the Wi-Fi Protected Access 2 sup iBot Security Advisories (RSS) - Microsoft 0 12-24-2007 07:00 AM
Print on a printer which is password protected Anuj UNIX for Dummies Questions & Answers 1 07-06-2005 10:44 AM
Multiple protected directories ericg UNIX for Dummies Questions & Answers 2 06-10-2002 07:58 PM
Creating a Password-Protected directory for ftp Uploads & Downloads NAL Security 3 06-03-2002 02:20 PM
I inhereted a Unix server that is password protected...Help! fxsaint UNIX for Dummies Questions & Answers 1 10-26-2000 05:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-17-2007
Registered User
 

Join Date: Dec 2006
Posts: 11
How to make script password protected

Hi All,

I want to make my script password protected.

i e: if somebody runs my script it should prompt for password.

Can somebody help me in to execute the same??

Thanks in Advance
Reply With Quote
Forum Sponsor
  #2  
Old 12-17-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 146
hi,
I got a very simple idea.

Write something like this in the beginning of your script for the password checking.

...
ACTUAL="perftest"
read -s -p "Password: " enteredpass
echo ""

[ "$enteredpass" != "$ACTUAL" ] && echo "Sorry" && echo "exiting" || echo "Conti.."
...

Since you will be storing your password in your script itself, you have to protect your shell script by using shc.
Generic shell script compiler(shc) creates a stripped binary executable version of the script specified with -f on the command line. (shc encrypts shell scripts using RC4)

Hope this helps.

//Jadu
Reply With Quote
  #3  
Old 12-17-2007
Registered User
 

Join Date: Dec 2006
Posts: 11
I am not very clear about shc,

Can you tell me how to make a sciprt as shc??
Reply With Quote
  #4  
Old 12-17-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 146
Well,
I have a post here,

Jadu's Workshop: How to protect a shell script

which will help you.
Reply With Quote
  #5  
Old 12-18-2007
Registered User
 

Join Date: Dec 2006
Posts: 11
how to Encrypt bash scripts?

Hi,

I tried encryting a bash script, and I received the below error...

-bash: shc: command not found

Is there a different command to execute bash scripts??
Reply With Quote
  #6  
Old 12-18-2007
Tytalus's Avatar
Registered User
 

Join Date: Jun 2003
Location: Scotland
Posts: 290
reasonably simple password encrypter process:

you could use perl to crypt a password e.g.:

perl -e "print crypt('password','AA');'\n'"

then use perl in your script to check the password e.g.:

/usr/bin/perl -e "print 'match' if crypt('password','AA') eq 'AA6tQYSfGxd/A';"

and do the test / exit or continue with script piece

but as noted already this does not hide the contents of the script - for very basic security it'll do though...
Reply With Quote
  #7  
Old 12-21-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 146
Quote:
Originally Posted by achararun View Post
Hi,

I tried encryting a bash script, and I received the below error...

-bash: shc: command not found

Is there a different command to execute bash scripts??
achararun you have to get shc install in your box if ! present, get it from here, Francisco Rosales, home page
and follow my blog link.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:28 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0