The first method (Gzexe):
This type of encryption is not a very safe method, but can satisfy the general encryption use, can conceal the password in the script and so on information.
It is the use of the system's own Gzexe program, it is not only encrypted, while compressing the file.
How to use:
Copy Code code as follows:
It will be the original unencrypted files back to file.sh~, while file.sh is turned into encrypted files;
The second method (SHC):
Use SHC to encrypt Linux shell scripts.
SHC is a professional tool for encrypting shell scripts. Its role is to convert the shell script into an executable binary file, which is a good solution to the script contains IP, password and so do not want to open the issue.
SHC's official website download address:
http://www.datsi.fi.upm.es/~frosal/sources/
Installation:
Copy Code code as follows:
Tar xzvf shc-3.8.6.tgz
CD shc-3.8.6
Mkdir-p/usr/local/man/man1
This step is necessary, otherwise the installation will be an error, SHC will install the command to the/usr/local/bin/directory, the Help document stored in the/usr/local/man/man1/directory, if the system does not have this directory, the installation will error, you can create this directory and then perform the installation
Copy Code code as follows:
This is to answer yes or Y, you can not return directly, or you will error
How to use:
The "-F" option specifies the program to encrypt
Copy Code code as follows:
Two files will be generated after the run, script-name.x and script-name.x.c. Where script-name.x is an executable binary file that is encrypted, it can be run with./script-name, SCRIPT-NAME.X.C is the original file (C language) that generates script-name.x.
The other SHC also provides a way to set a valid execution time, you can first use SHC to convert the shell program to binary, plus expiration times, such as:
Copy Code code as follows:
# shc-e 18/10/2006-m "It's Too late to run this script"-F SCRIPT.S