Can I prevent a script from being viewed?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Can I prevent a script from being viewed?
# 1  
Old 03-09-2017
Can I prevent a script from being viewed?

i've vi'ed some scripts in the past and when i did, my screen froze. i had to go to another terminal and kill the vi process before i was able to get back my screen.

how can i replicate this behavior on purpose? i want be able to do this also if the file or script was doubled clicked, say through the GUI of a File browser.
# 2  
Old 03-09-2017
Hello SkySmart,

How about the usual way by NOT providing the permissions to those to whom you don't want go view the content. Not sure about your UI(either you are having authentication process in it or not).

Thanks,
R. Singh
These 3 Users Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 03-10-2017
If they have to be able to read it to execute it for their job, consider writing a calling script that will use sudo to elevate the permissions so they can still do their job when you have locked the real script away from prying eyes.

So, if you have my_script that is sensitive, change the permissions so that they cannot read it and rename it to my_script.protected

Then create a public script that just contains something like this:-
Code:
#!/bin/ksh

sudo $0.protected $@

Using $0 means that it should find the protected script down the same way it found your open script. Of course, if you rely on the userid within the script you might have to work around this by determining who is logged on to the terminal. The whoami command might help if that is the case.


I hope that this helps,
Robin
These 3 Users Gave Thanks to rbatte1 For This Post:
# 4  
Old 03-10-2017
This extremely common question always has the same inescapable conclusion.

Moderator's Comments:
Mod Comment If your database/machine/client can decrypt it at will without secrets -- so can anyone else.


Yes, but --

Encryption does not work that way.

But what if --

Encryption does not work that way.

Maybe if it --

Encryption does not work that way.

To prevent people from reading your scripts/passwords, chmod.

To prevent people getting access to something which reads the scripts/passwords, sudo.

To prevent root from getting at it... You're out of luck.

This question fools everyone eventually... I spent a long while earlier this year down a rabbithole trying to find a way to make arbitrary apache suexec secure, until I realized I was fighting what amounts to the same problem -- how to prove identity to the computer without using secrets.

Last edited by Corona688; 03-10-2017 at 11:35 AM..
These 6 Users Gave Thanks to Corona688 For This Post:
# 5  
Old 03-10-2017
This User Gave Thanks to jgt For This Post:
# 6  
Old 03-11-2017
If you don't want anyone viewing your content, an option would be to encrypt the file with a secure passphrase.

On Solaris, use encrypt/decrypt
On Linux, use gpg2

Last edited by Don Cragun; 03-28-2017 at 01:33 AM.. Reason: Add ICODE tags.
This User Gave Thanks to dn888 For This Post:
# 7  
Old 03-14-2017
Quote:
Originally Posted by dn888
If you don't want anyone viewing your content, an option would be to encrypt the file with a secure passphrase.

On Solaris, use encrypt/decrypt
On Linux, use gpg2
But then they could only run the program if they knew the passphrase - either that, or include the password in the program, which leaves you with the same problem!
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file

Greetings Experts, I am on AIX using ksh; I am processing the input files and generating a awk_output.txt file using AWK. By reading that awk_output.txt file, I am building a output.html file which is cat and then fed to /usr/sbin/sendmail .When the shell script is triggered through command... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. Red Hat

Any Help About this script how can i prevent client to use it ?

Hello i have server cpanel on centos 6 an there is a client used script to hack other accounts the script is like this _____ __________ <?php $auth_pass = "7815696ecbf1c96e6894b779456d330e"; $color = "#df5"; $default_action = 'FilesMan'; $default_use_ajax = true;... (1 Reply)
Discussion started by: jackmio
1 Replies

3. Shell Programming and Scripting

How to prevent a shell script from copy or read from Users

I have a script which do validation check and perform code migration from one env. to another, this is built for users/developers. How can I prevent this shell script from copy or read from users, as they can modify it and run it as per their requirement where as this has to be standard script and... (1 Reply)
Discussion started by: pramendra
1 Replies

4. UNIX for Dummies Questions & Answers

tcsh: how to prevent a foreach from terminating a script when the result is null?

Sorry if this has been answered. I did search both Google and this site and did find this post: unix.com/unix-dummies-questions-answers/152992-how-ignore-errors-script.html However, it wasn't answered. I have the same question - how do you prevent a tcsh script from terminating when the... (4 Replies)
Discussion started by: deepstructure
4 Replies

5. Shell Programming and Scripting

how do i prevent $ from being commented out if no value is present? (Bash Script)

Hey guys, I want to paste a code in a .php file via a bash script. I am on ubuntu 10.04. The problem is if the values for $ aren't present, then all of them would be removed by the script. An example of my script (I modified it for this thread to prevent it from being overly complicated) ... (2 Replies)
Discussion started by: xxxx
2 Replies

6. Shell Programming and Scripting

Prevent wrong user from using shell script for multiple remote servers

Hi, I am running a shell script from a central server to multiple remote servers using the following code: application_check() { # Linux/UNIX box with ssh key based login SERVERS=`cat /tmp/server-details` # SSH User name USR="user" # create new file > /tmp/abc.log # connect... (2 Replies)
Discussion started by: mystition
2 Replies

7. Shell Programming and Scripting

Cron job to prevent simultaneous script

I'm using a shared server on Hostgator (Linux CentOS). I'm trying to set a cron job using the Control Panel that will check if its already running before starting a new one. I've tried the following... * * * * * && but I get this error emailed to me... /bin/sh: line 0: Any... (5 Replies)
Discussion started by: tech9821
5 Replies

8. Shell Programming and Scripting

script - how to prevent in parallel run

I have one shell script which is being accessed by many jobs at same time. I want to make the script such that , other job should wait for the script if script is being used by some other job. Is there any way to implement it in script level ? Gops (1 Reply)
Discussion started by: Gopal_Engg
1 Replies

9. Shell Programming and Scripting

how to prevent multiple email notifications from monitoring script

Hi everyone, I am in the process of trying to decide the correct way to solve a particular scripting/email issue I have and would appreciate any advice. We have a cronjob running every 10 mins to check disk size on the server and if this exceeds a certain percentage then it will email a... (2 Replies)
Discussion started by: si_linux
2 Replies

10. OS X (Apple)

Use UNIX to track web sites viewed?

I'm on OSX 10.4. I was wondering if you can use UNIX terminal to track what web sites have been viewed on this Mac... Thank you! (1 Reply)
Discussion started by: tracymanusa
1 Replies
Login or Register to Ask a Question