The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to do file locking? yang UNIX for Dummies Questions & Answers 2 07-29-2008 12:32 PM
Locking in Unix? nguoidoius UNIX for Dummies Questions & Answers 1 01-24-2008 01:50 AM
locking problem venkatramana UNIX for Dummies Questions & Answers 1 12-24-2007 03:10 PM
Locking a file in ksh thanuman UNIX for Dummies Questions & Answers 1 04-27-2005 11:01 AM
File Locking penfold UNIX for Advanced & Expert Users 1 04-11-2005 12:47 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2008
dave123 dave123 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 46
Locking a script

Hello everyone

Im sure this has been asked lots of times before, but after endless searching i cant find what i need.
How can i make a bash script unreadable to all, including root, but still executable, im not worried about editing it again etc... , is there a way to convert it or something, i have tried chmod and chown, but root is still able to view the script, or is not possible.
Thanks in advance for any help.

Dave
  #2 (permalink)  
Old 11-17-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,262
Quote:
How can i make a bash script unreadable to all, including root
This is not possible. Root will always be able to do what it wants. If you work with passwords etc. in there and don't want to have it visible, maybe use md5 encryption with perl or something.

Edit: Or write it in C or Perl and compile it.

Last edited by zaxxon; 11-17-2008 at 08:38 AM.. Reason: Added something
  #3 (permalink)  
Old 11-17-2008
bsddaemon's Avatar
bsddaemon bsddaemon is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 37
Quote:
Originally Posted by dave123 View Post
Hello everyone

Im sure this has been asked lots of times before, but after endless searching i cant find what i need.
How can i make a bash script unreadable to all, including root, but still executable, im not worried about editing it again etc... , is there a way to convert it or something, i have tried chmod and chown, but root is still able to view the script, or is not possible.
Thanks in advance for any help.

Dave
Root is your machine's god.

The only thing I can think of is to encrypt your bash file.
  #4 (permalink)  
Old 11-17-2008
dave123 dave123 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 46
Thanks guys,
is it possible to encrypt passwords in the script, i know that when i make a kickstart file, it gives the option to encrypt the password, and its unreadable but still usable, not that im wording this very well, but hopefully you get what i mean.

Thanks
Dave
  #5 (permalink)  
Old 11-17-2008
bsddaemon's Avatar
bsddaemon bsddaemon is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 37
Have a look at openssl and gnupg
  #6 (permalink)  
Old 11-17-2008
dave123 dave123 is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 46
Okay i found one way with rot13
Say your script is called "script.sh". You can "encrypt" it with:

Quote:
shell$ cat script.sh | tr 'a-zA-Z' 'n-za-mN-ZA-M' >skrypt.sh
Then put this code at the very start of the encrypted script "skrypt.sh":
Quote:
#!/bin/sh
FIFO=/tmp/__skrypt_$(date +%F)_$$
mkfifo $FIFO
sh $FIFO &
tr 'a-zA-Z' 'n-za-mN-ZA-M' >$FIFO <<EOF_EOF
...and put these lines at the very end of the "encrypted" script:
Quote:
EOF_EOF
rm $FIFO >/dev/null 2>/dev/null
This isnt the safest but will deter most, plus you can make it stronger by double encrypting etc...

I am trying to work out another way with md5 which would be better i think!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0