Locking a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Locking a script
# 1  
Old 11-17-2008
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  
Old 11-17-2008
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  
Old 11-17-2008
Quote:
Originally Posted by dave123
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  
Old 11-17-2008
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  
Old 11-17-2008
Have a look at openssl and gnupg
# 6  
Old 11-17-2008
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!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Which process/script is locking account ?

There is a account - ohsuser on Solaris-10 zone. It is getting locked every 2-3 minutes. Can I know, what is process or script, which is using this account and locking it ? root@tswsd23-prdt01:/root# cat /var/adm/messages | tail -10 Sep 24 11:05:53 tswsd23-prdt01 nmo: Excessive (3) login... (5 Replies)
Discussion started by: solaris_1977
5 Replies

2. Red Hat

Locking Down SFTP

Hi List, I'm sure this has been done before and there must be several ways to skin the cat on this topic. What I am trying to achieve is set up user accounts for use with SFTP based on the standard OpenSSH protocol. And I want to be able to lock them down so that they cannot browse outside of... (2 Replies)
Discussion started by: landossa
2 Replies

3. UNIX for Advanced & Expert Users

File locking

i am working on a device runnin on linux....i have configured the samba server in the device such that my windows PC can access a shared folder in the device. Also in the device i am runnin some programs which access the files in this shared folder. What i want to know is whether there is any way i... (1 Reply)
Discussion started by: abhinx
1 Replies

4. Shell Programming and Scripting

locking mechanism

I have a shell script. How can use some kind of locking mechanism to ensure that the script is not being executed by two people at the same time? (3 Replies)
Discussion started by: tjay83
3 Replies

5. UNIX for Dummies Questions & Answers

how to do file locking?

how to ensure all files are being locked while updateing some files? example when i want to update the password and shadow file in unix. how do i implement file locking?? please advice thanks (2 Replies)
Discussion started by: yang
2 Replies

6. UNIX for Dummies Questions & Answers

file locking

how do i implement file locking in unix? example if i want to update a file, i would like to use file locking. how do i implement it? i am using shell script thanks (3 Replies)
Discussion started by: yang
3 Replies

7. UNIX for Dummies Questions & Answers

Locking in Unix?

Hi all! I want to know about Mapping Filesystems to Multiprocessor Systems.( lock ...) and Traditional UNIX Locking Primitives. Can you help me? (1 Reply)
Discussion started by: nguoidoius
1 Replies

8. UNIX for Dummies Questions & Answers

locking problem

Hi... after unlock my computer from lock, all telnet windows which i opened previously are closing automaticaly... i hope u understand....plz give solution... (1 Reply)
Discussion started by: venkatramana
1 Replies

9. UNIX for Advanced & Expert Users

File Locking

Hi, Does anyone know what happens when two processes are simultaneously trying to write to a single file in UNIX (AIX)? Cheers (1 Reply)
Discussion started by: penfold
1 Replies

10. SCO

System Locking Up

I have a server that is locking up pretty frequently for serveral months. I have about 4 dumb terminals running off this server and it appears that when the system is about to lock up it starts to run really slow on one of the terminals and then the rest follow suit until it just craps out. We... (1 Reply)
Discussion started by: mcrawfo4
1 Replies
Login or Register to Ask a Question