Encrypt shell scripts in CentOS

Source: Internet
Author: User

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.