How to Encrypt Shell Script

We all know that anyone can read shell script.Think if any one gets access to the shell script which has root password and all stored in it. Its really a security risk. Now we have a solution for that ie all this risk can be avoided if the shell script is encrypted and then executed. The utility used for that is called shc

I will explain how to install it and then use it for the encrypting purpose

1) Download from http://www.datsi.fi.upm.es/~frosal/sources/shc-3.7.tgz

wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.7.tgz

2) Untar it

tar -xzvf shc-X.X.tgz

3) To install it follow the below given steps

cd shc-X.X/
make
make install

4) After install it will create a binary called shc, use it to encrypt the shell scripts
5) Write a shell script, lets call it heloworld.sh

#!/bin/bash
echo ” Helo world ”

6) To test shc execute the command

shc -f heloworld.sh

Option -f is used to encrypt
7) Now you will get an encrypted version of the script. It will be named something like heloworld.sh.x
8) Its an encrypted version and you can execute it as you wish

eg ./heloworld.sh.x

9) You have an encrypted shell script.

One Response to “How to Encrypt Shell Script”

  1. 1adjacenton 12 Jan 2022 at 10:00 pm

    2taciturn…

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.