I'm running Ubuntu. I need to know any way to obfuscate .sh shell script file contents in order to make it very difficult to read.

Any suggestion are welcome, including using online obfuscator.

  • 5
    I won't downvote just because I don't like the idea, but EEEWWW!. This goes against everything FOSS.
    – Caleb
    Aug 24, 2011 at 21:56
  • 1
    I'm curious about your use case. Apr 15, 2016 at 17:42

4 Answers 4


This really depends on who you are trying to prevent from reading the script and what resources you are expecting the system to have.

One option is to simply use many different programs to do different parts of your script: shell, awk, sed, perl, etc. as well as lots of obscure parameters of tools, forcing the reader to constantly refer to man pages.

Even within a shell, you can create unnecessary functions and variables, making them interdependent in confusing ways. And, of course, give them misleading names.

More complicated, you can append binary data to the end of your shell and have your shell extract and execute the binary. I believe nVidia's Linux drivers, and Sun's JDK are installed this way (the binary data is an RPM, which the shell extracts and installs). Another example I just downloaded the other day is the soapUI program.

In that vein, it is possible to have a text file that can be compiled or interpreted in multiple languages, so it could start as a shell, compile itself as a C program and execute the result. The IOCCC has some examples.

  • The .sh files will be copied to many computer. It contains password and some more sensitive information. Just in case if it fall to the wrong hand, they don't know what is that obfuscated codes means. Aug 24, 2011 at 3:33
  • 12
    Obfuscation is not encryption, which is what you really need for things like a password.
    – phunehehe
    Aug 24, 2011 at 3:43
  • Then I would recommend a either the binary data approach I mentioned or consider some way of transmuting the password, using math or a translation table (like ROT13, but more complicated). Separate from obfuscation, can't you just change the permissions so the script can be executed without being read? You could use chmod 4711 myscript.sh.
    – Klox
    Aug 24, 2011 at 3:50
  • 4
    You can't execute something you can't read.
    – jw013
    Sep 18, 2012 at 16:54
  • @jw, yeah you're right. I don't remember what I was thinking when I wrote that. On that vein, he could store the password in a separate file with restricted permissions and still use privilege escalation (chmod 4755) on the script.
    – Klox
    Sep 24, 2012 at 22:44

You can use shc for purpose.

So you can use this command to encode:

shc -f script.sh

And it makes two files:


That .c is in C programming language file. And .x is executable file.

So for run it use:

chmod +x script.sh.x

Obfucation is different from compilation. There are a number of scripts out there on the Internet that do a reasonable job of obfuscating Bourne, Bash or Korn shell scripts.

Here is one such script: obfuscate_shell_script-20011012.html


You can copy your script to a site like kinglazy.com to have an obfuscated (executable) copy generated for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.