Shell scripts are especially important in the daily operations, and often we write shel scripts that involve a lot of privacy information, including passwords, which requires the shell script to be encrypted and the results to be executed. The following article introduces two ways to encrypt shell scripts:
SHC encryption Method 1, SHC Software Installation
CD/MNT//Enter or create a directory, that is, select the download location
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz//download package
Tar zxvf shc-3.8.9.tgz-c/opt//Unpacking Package
Decompression after the completion of the package is not anxious to install, first install the environment-dependent package:
Yum Install gcc gcc-c++ make-y
cd/opt/shc-3.8.9
Make install//perform installation
Note: If the installation times below are incorrect, you will need to create a working directory.
Mkdir-p/usr/local/man/man1//Create software default working directory
Make install//install again
2. Encrypt shell scripts
Cd/opt
Ls-l
-rw-r--r--. 1 root root 38 6月 22 09:54 123.sh
Shc-r-F 123.sh//SHC Encryption for scripts
Ls-l
-rwx--x--x. 1 root root 11184 6月 22 09:56 123.sh.x //加密后的可执行的二进制文件-rw-r--r--. 1 root root 9456 6月 22 09:56 123.sh.x.c //生成123.sh.x的原文件(c语言)
./123.sh.x//Execute encrypted shell script
this is test shell //依旧可正常输出
Gzexe Encryption method
The Gzexe encryption shell script is the system's own, its function is relatively weaker than SHC, can only meet the general requirements.
Cd/opt
Ls-l
-rw-r--r--. 1 root root 38 6月 22 09:54 123.sh
Gzexe 123.sh//Encrypt files
Ls-l
-rw-r--r--. 1 root root 864 6月 22 10:05 123.sh //加密后文件-rw-r--r--. 1 root root 38 6月 22 09:54 123.sh~ //原文件备份文件
Note: The system comes with the Gzexe program, it is not only encrypted, while compressing the file, and encrypted, the original file was backed up as a 123.sh~ file.
./123/sh
this is test shell //依旧可正常输出
Shell script Encryption Form