Linux下文件级加密方法总结


(1)gzexe加密
 
[root@ECS iclound]# ifconfig >>ip.txt
[root@ECS iclound]# gzexe ip.txt
[root@ECS iclound]# gzexe -d ip.txt                                     //解密
 
(2)用tar命令对文件进行加密
 
[root@ECS iclound]# tar -zcf - ip.txt | openssl des3 -salt -k pwd@123 | dd of=ip_en.txt.des3                            //加密
[root@ECS iclound]# dd if=ip_en.txt.des3 | openssl des3 -d -k pwd@123 | tar zxf -                                          //解密
 
 
(3)用tar结合openss对文件进行加密
 
[root@ECS iclound]# tar -czf -* | openssl enc -e -aes256 -out ip.txt.tar.gz                                                    //加密
[root@ECS iclound]# openssl enc -d -aes256 -in ip.txt.tar.gz | tar xz -C /root/                                             //解密
 
 
 
(4)用shc加密(仅仅对shell脚本加密)
 
shc是一个专业的加密shell脚本的工具.它的作用是把shell脚本转换为一个可执行的二进制文件,这个办法很好的解决了脚本中含有IP、密码等不希望公开的问题。
[root@ECS iclound]# cd /usr/local/src/
[root@ECS src]# tar -zvxf shc-3.8.9.tgz
[root@ECS shc-3.8.9]# mkdir -p /usr/local/man/man1
[root@ECS shc-3.8.9]# make install
 
[root@ECS iclound]# shc -r -f 01.sh                                          //生成二进制
[root@ECS iclound]# ls -l
总用量 28
-rw-r--r-x 1 root root    33 12月 17 14:08 01.sh
-rwx--x--x 1 root root 11232 12月 17 14:09 01.sh.x
-rw-r--r-- 1 root root  9467 12月 17 14:09 01.sh.x.c                           //.x为加密后的二进制
 
(5)用ZIP加密
 
[root@ECS iclound]# zip -e ip.txt.zip ip.txt                                       //加密
Enter password:
Verify password:
  adding: ip.txt (deflated 71%)
[root@ECS iclound]#
[root@ECS iclound]# unzip ip.txt.zip                                               //解密
Archive:  ip.txt.zip
[ip.txt.zip] ip.txt password:
 
(6)用GnuPG加密
 
GnuPG全程是GNU隐私保护,通常称为GPG,通常只能针对文件加密无法对文件夹加密
[root@ECS iclound]# yum -y install gnupg
[root@ECS iclound]# gpg2 -c ip.txt                                //加密
[root@ECS iclound]# gpg2 ip.txt.gpg                            //解密


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM