Archive for the tag 'encrypt'

SBDavid

How to Encrypt Shell Script

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.

SBDavid

How to encrypt file with passphrase

How to encrypt file with passphrase

Mcrypt is a simple crypting program, a replacement for the old unix crypt(1). When encrypting or ecrypting a file, a new file is created with the extension .nc and mode 0600. The new file keeps the modification date of the original. The original file may be deleted by specifying the -u parameter. If no files are specified, the standard input is encrypted to the standard output.

$ mcrypt -uz file1

Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase:
Enter passphrase:
File file1 was encrypted.

-d, –decrypt decrypts.
-z, –gzip Use gzip to compress files before encryption.
-u, –unlink Unlink the input file after encryption or decryption.