Linux可通过工具对文件、目录或磁盘加密,以下是常用方法:
文件/目录加密
sudo apt install gnupg
(Debian/Ubuntu)。gpg --encrypt --recipient "收件人" file.txt
,生成file.txt.gpg
。gpg --decrypt file.txt.gpg > file.txt
。openssl enc -aes-256-cbc -in file.txt -out file.enc -salt
。openssl enc -d -aes-256-cbc -in file.enc -out file.txt
。7z a -mhe=on -p密码 archive.7z file.txt
。7z x -p密码 archive.7z
。磁盘/分区加密
cryptsetup luksFormat /dev/sdb1
。cryptsetup open /dev/sdb1 my_encrypted
,格式化后挂载。sudo apt install ecryptfs-utils
,通过mount -t ecryptfs
挂载。encfs ~/encrypted ~/decrypted
,解挂用fusermount -u
。注意事项
参考来源: