Method 1 (gzexe ):
This encryption method is not very safe, but can meet the general encryption purpose, can conceal the password and other information in the script.
It uses the built-in gzexe program, which not only encrypts but also compresses files.
Usage:
Gzexe file. sh
It backs up unencrypted files as file. sh ~ At the same time, file. sh is converted into an encrypted file;
Method 2 (shc ):
Use shc to encrypt Linux shell scripts.
Shc is a professional tool for encrypting shell scripts. it is used to convert a shell script into an executable binary file. This solution solves the issue that the script contains IP addresses, passwords, and other issues that do not need to be disclosed.
Shc:
Click to download
Installation:
Tar xzvf shc-3.8.6.tgz
Cd shc-3.8.6
Mkdir-p/usr/local/man/man1
This step is required. Otherwise, an error will be reported during the installation process. shc will run the installation command to the/usr/local/bin/directory; store the help document in the/usr/local/man/man1/directory. If this directory is not found in the system, an error will be reported during installation. You can create this directory and then perform installation.
Make install
This is to answer yes or y. You cannot press enter directly. Otherwise, an error will be reported.
Usage:
-F option specifies the program to be encrypted
Shc-r-f script-name
Two files, script-name.x and script-name.x.c, are generated after running. where the script-name.x is an encrypted executable binary file;. /script-name can be run, the script-name.x.c is to generate the original file of the script-name.x (C language ).
In addition, shc provides a method to set the validity period. You can first use shc to convert the shell program to binary and add the expiration time, for example:
# Shc-e 18/10/2006-m "It's too late to run this script"-f script. s