A goal is a dream with a deadline. Much effort, much prosperity.
为什么要加密Shell脚本呢?当然是为了安全!
可能脚本里面涉及到密码之类的就需要进行加密了
一、下载安装shc工具
要保护自己编写的shell脚本程序,方法有很多,最简单的方法有两种:1、加密 2、设定过期时间,下面以shc工具为例说明:
shc是一个加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件.
[[email protected] ~]# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz [[email protected] ~]# tar xf shc-3.8.7.tgz [[email protected] ~]# cd shc-3.8.7 [[email protected] shc-3.8.7]# mkdir /usr/local/shc [[email protected] shc-3.8.7]# make test [[email protected] shc-3.8.7]# make [[email protected] shc-3.8.7]# make test [[email protected] shc-3.8.7]# make strings [[email protected] shc-3.8.7]# make install #这步需要有root权限
进行加密
[[email protected] test]# ls script.sh [[email protected] test]# cat script.sh #!/bin/bash echo "123123" echo "123123" echo "123123" echo "123123" echo "123123" echo "123123" echo "123123" [[email protected] test]# shc -r -f script.sh [[email protected] test]# ls script.sh script.sh.x script.sh.x.c [[email protected] test]# ./script.sh.x [[email protected] test]# ./script.sh.x 123123 123123 123123
·····