How to encrypt bash shell script in Linux ?

Today in this post, we will see how to encrypt a shell script in Linux.

Lets have a look at this step by step.

1. Download shc source code from below links.
Or, from GIT Repo:


We can download the RPM also from here:


2. Compile and install shc.

# ./configure
# make
# make install


3. Encrypt a file named

[mike@ngelinux001 01_script]$ cd shc-master
[mike@ngelinux001 shc-master]$ ./shc -v -r -T -f
shc shll=bash
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: cc -o
shc: strip
shc: chmod go-r
[mike@ngelinux001 shc-master]$

[mike@ngelinux001]$ ls -ltr
total 176
-rwxr-xr-x 1 mike ngegroup1  7952 Oct 11 11:43
-rw-r--r-- 1 mike ngegroup1 50088 Nov 30 11:36
-rwx--x--x 1 mike ngegroup1 21120 Nov 30 11:36


4. Try to read the encrypted file.

[mike@ngelinux001 01_transfer_v1]$ more ./
******** ./ Not a text file ********
[mike@ngelinux001 01_transfer_v1]$

[mike@ngelinux001 01_transfer_v1]$ cat ./ 
ELF>▒   @@▒K@@@@@@▒@@@@▒▒   ` `4*h+ ( ( `( `▒@@DDP▒td▒▒@▒@ddQ▒t/lib64/▒▒Xt▒]▒5t0▒/Px▒▒0▒@▒ݣkʼn▒Ĺ▒@9▒S "▒y▒7L▒▒r▒Z>kE▒▒2▒!@J▒!@J▒@J▒▒uiputen▒▒!`@J`HJ`▒!`▒!`▒!`▒!`▒!`"""`ntf"`ollstrerror__libc_start_main__environ__xstatGLIBC_2.7GLIBC_2.2.5ii

So finally our bash script is encrypted and can’t be read by anyone.

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments