在 Ubuntu 16.04 上使用 EncFS 加密你的数据
本教程适用于这些操作系统版本
- Ubuntu 16.04(Xenial Xerus)
- Ubuntu 12.10(Quantal Quetzal)
在此页
- 1 条初步说明
- Encfs 安全信息
EncFS 在用户空间提供加密文件系统。它无需任何特殊权限即可运行,并使用 FUSE 库和 Linux 内核模块来提供文件系统接口。它是直通文件系统,而不是加密块设备,这意味着它是在现有文件系统之上创建的。本教程介绍如何在 Ubuntu 16.04 (Xenial Xerus) 上使用 EncFS 来加密数据。
1 初步说明
在本教程中,我在我的 Ubuntu 16.04 系统上使用用户名 falko。安全审计揭示了当前 encfs 实施中的一些问题,请参阅下面的安全警告,以确定您使用 encfs 的方式是否受到这些问题的影响。 encfs 的替代方法是 ecryptfs (https://launchpad.net/ecryptfs),我将在另一个教程中介绍它。
Encfs 安全信息
\根据 Taylor Hornby (Defuse Security) 的安全审计,Encfs 的当前实施容易或可能容易受到多种类型的攻击。例如,对加密数据具有读/写访问权限的攻击者可能会降低随后加密数据的解密复杂性没有被合法用户注意到,或者可能使用时序分析来推断信息。在这些问题得到解决之前,在可能发生此类攻击的情况下,encfs 不应被视为敏感数据的安全之家。\
2 安装EncFS
EncFS 可以按如下方式安装(我们需要 root 权限,因此,我们使用 sudo):
sudo apt-get -y install encfs
您现在应该查看 EncFS 手册页以熟悉其选项:
man encfs
3 使用 EncFS
我现在将在我的主目录中创建加密和解密的目录:
mkdir -p ~/encrypted
mkdir -p ~/decrypted解密目录充当加密目录的挂载点。要将 ~/encrypted 挂载到 ~/decrypted,只需运行:
encfs ~/encrypted ~/decrypted
如果您是第一次运行此命令,则会启动 EncFS 安装程序,并且您必须为加密卷定义一个密码:
:~$ encfs ~/encrypted ~/decrypted
Creating new encrypted volume.
Please choose from one of the following options:
enter "x" for expert configuration mode,
enter "p" for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?> <-- pParanoia configuration selected.
Configuration finished. The filesystem to be created has
the following properties:
Filesystem cipher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 4:0:2
Key Size: 256 bits
Block Size: 1024 bytes, including 8 byte MAC header
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File data IV is chained to filename IV.
File holes passed through to ciphertext.-------------------------- WARNING --------------------------
The external initialization-vector chaining option has been
enabled. This option disables the use of hard links on the
filesystem. Without hard links, some programs may not work.
The programs 'mutt' and 'procmail' are known to fail. For
more information, please see the encfs mailing list.
If you would like to choose another configuration setting,
please press CTRL-C now to abort and start over.Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism. However, the password can be changed
later using encfsctl.New Encfs Password: <-- Enter a secure password here
Verify Encfs Password: <-- Enter the secure password a second time请务必记住密码,因为如果忘记密码,将无法恢复加密数据!
您现在应该在输出中找到 EncFS 卷
mount
:~$
和
df -h
:~$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 980M 0 980M 0% /dev
tmpfs 200M 6.0M 194M 3% /run
/dev/mapper/server1--vg-root 27G 1.7G 24G 7% /
tmpfs 999M 0 999M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 999M 0 999M 0% /sys/fs/cgroup
/dev/sda1 472M 55M 393M 13% /boot
tmpfs 200M 0 200M 0% /run/user/1000
encfs 27G 1.7G 24G 7% /home/falko/decrypted要以加密形式保存数据,请将数据放入解密目录,就像处理普通目录一样:
cd ~/decrypted
echo "hello foo" > foo
echo "hello bar" > bar
ln -s foo foo2如果你检查目录的内容,你会发现你可以看到未加密的形式......
ls -l
:~/decrypted$ ls -l
total 8
-rw-rw-r-- 1 falko falko 10 Apr 26 18:54 bar
-rw-rw-r-- 1 falko falko 10 Apr 26 18:54 foo
lrwxrwxrwx 1 falko falko 3 Apr 26 18:54 foo2 -> foo...在加密目录中,其加密:
cd ~/encrypted
ls -l:~/encrypted$
要卸载加密卷,请运行:
cd
fusermount -u ~/decrypted检查...的输出
mount
... 和...
df -h
...您将看到不再列出 EncFS 卷。
要再次安装它,请运行
encfs ~/encrypted ~/decrypted
您将被要求输入您之前定义的密码:
[电子邮件受保护]:~$encfs ~/encrypted ~/decrypted
EncFS 密码:<-- yoursecretpassword如果您指定了正确的密码,这会将 ~/encrypted 目录挂载到 ~/decrypted 从那里您可以以未加密的形式访问您的加密数据。如果您忘记密码,您的加密数据就会丢失!
如果要更改密码,可以使用
encfsctl passwd ~/encrypted
命令。
[email :~$encfsctl passwd ~/encrypted
输入当前 Encfs 密码
EncFS 密码:<-- yoursecretpassword
输入新 Encfs 密码
新 Encfs 密码:<-- newsecretpassword
验证 Encfs 密码:<-- newsecretpassword
音量密钥已成功更新。4个链接
- EncFS:http://www.arg0.net/encfs
- Ubuntu:http://www.ubuntu.com/