Many people write Shell scripts and want to let others use them, but do not want to disclose the source code, so the Shell scripts need to be encrypted. Linux has a very useful Shell encryption component called shc.

Today, I am bringing you a one-click installation script and compilation and installation tutorial for shc. Those who enjoy tinkering can choose to compile it themselves, while the one-click installation script is prepared for lazy users and beginners. Without further ado, here is the script!

Installation Script

Log in to the server via SSH and run the following command directly. Only one command is needed:

wget -qO- https://shc-install-script-url | bash

If you see the error bash: wget: command not found, execute the following first:

yum -y install wget

Then run the one-click installation script again.

Compilation and Installation

Compilation must be performed in the root directory:

yum -y install gcc gcc-c++
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
tar vxf shc-3.8.7.tgz
mkdir -p /usr/local/man/man1
cd shc-3.8.7
make test && make strings && make install

Usage

Example: encrypt xxxx.sh:

shc -r -v -f xxxx.sh
  • -r: Makes the script suitable for other operating systems
  • -v: Displays the encryption process
  • -f: Followed by the file to be encrypted

Two files will be generated after execution:

  • xxxx.sh.x: A binary file. After renaming it, grant it execution permission with chmod +x xxxx.sh, and it can then be executed.
  • xxxx.sh.x.c: A C language file. It is not needed and can be deleted.