There's a half truth to the previous statements. You can setup a script so that it's not readable by the user, but still executable. The process is a little drawn out, but it's doable by making an exception in /etc/sudoer so that the user can run the script as yourself temporarily without being prompted for a password. Example below:
Some script I want to share with a user:
me@OB1:~/Desktop/script/$ chmod 700 somescript.pl me@OB1:~/Desktop/script/$ ls -l somescript.pl -rwx------ 1 me me 4519 May 16 10:25 somescript.pl
Make a shell script that calls 'somescript.pl' and save it in /bin/ :
me@OB1:/bin$ sudo cat somescript.sh [sudo] password for me: #!/bin/bash sudo -u me /home/me/Desktop/script/somescript.pl $@
OPTIONAL STEP Make a symlink to somescript.sh in /bin/:
sudo ln -s /bin/somescript.sh /bin/somescript
Make sure the shell script is readable/executable to the user (no write access):
sudo chmod 755 /bin/somescript.sh me@OB1:/bin$ ls -l somescript* lrwxrwxrwx 1 root root 14 May 28 16:11 somescript -> /bin/somescript.sh -rwxr-xr-x 1 root root 184 May 28 18:45 somescript.sh
Make exception in /etc/sudoer by adding these lines:
# User alias specification User_Alias SCRIPTUSER = me, someusername, anotheruser # Run script as the user 'me' without asking for password SCRIPTUSER ALL = (me) NOPASSWD: /home/me/Desktop/script/somescript.pl
PROOF IN THE PUDDING:
someuser@OB1:~$ somescript ***You can run me, but can't see my private parts!*** someuser@OB1:~$ cat /home/me/Desktop/script/somescript.pl cat: /home/me/Desktop/script/somescript.pl: Permission denied
This method should be better than trying to obfuscate with Filter::Crypto
or PAR::Filter::Crypto
or Acme::Bleach
which can be reversed engineered by a determined user. Same goes for compiling your script to binary. Let me know if you find something wrong with this method. For more advanced users you may want to remove the User_Alias section completely and replace SCRIPTUSER with '%groupname'. This way you can manage your script users with usermod
command.