如何在 Debian 8 上使用 EncFS 加密您的数据 (Jessie)
本教程适用于这些操作系统版本
- Debian 7(喘息)
- Debian 6(挤压)
在此页
- 1 条初步说明
- 2 安装 EncFS
- 3 使用 EncFS
- 4 挂载和卸载 encfs 卷
- 5 更改 encfs 密码
- 6 个链接
EncFS 在用户空间提供了一个加密的文件系统。它无需任何特殊权限即可运行,并使用 FUSE 库和 Linux 内核模块来提供文件系统接口。它是一个直通文件系统,而不是加密块设备,这意味着它是在现有文件系统之上创建的。本教程展示了如何在 Debian Jessie 上使用 EncFS 来加密数据。
1 初步说明
在本教程中,我在我的 Debian Jessie 系统上使用用户名 till。
2 安装EncFS
在您的服务器或桌面上以 root 用户身份登录,当您使用远程服务器时,您可以,例如通过 SSH 登录。 EncFS 可以用 apt 安装如下(我们需要 root 权限):
apt-get -y install encfs
您将收到以下警告:

Encfs security information
According to a security audit by Taylor Hornby (Defuse Security), the current implementation of Encfs is vulnerable or potentially vulnerable to multiple types of attacks. For example, an attacker with read/write access to encrypted data might lower the decryption complexity for subsequently encrypted data without this being noticed by a legitimate user, or might use timing analysis to deduce information.
Until these issues are resolved, encfs should not be considered a safe home for sensitive data in scenarios where such attacks are possible.
虽然 encfs 可能不是为大型组织或政府加密数据的解决方案,也不能用于第三方以上述方式对您的数据进行写访问的服务器,但它仍然足够安全,供个人在您的网站上使用桌面。当您决定使用 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.
?> <-- p
Paranoia 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 3:0:1
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
Verify Encfs Password: <-- enter a secure password
:~$
请务必记住密码,因为如果忘记密码,将无法恢复加密数据!
您现在应该在输出中找到 EncFS 卷
mount
:~$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_inodes=125548,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,relatime,size=204216k,mode=755)
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=23,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw,relatime)
encfs on /home/till/decrypted type fuse.encfs (rw,nosuid,nodev,relatime,user_id=5004,group_id=5005,default_permissions)
和
df -h
:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 57G 2.2G 52G 5% /
udev 10M 0 10M 0% /dev
tmpfs 200M 4.7M 195M 3% /run
tmpfs 499M 0 499M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 499M 0 499M 0% /sys/fs/cgroup
encfs 57G 2.2G 52G 5% /home/till/decrypted
要以加密形式保存数据,请将数据放入解密目录,就像处理普通目录一样:
cd ~/decrypted
echo "hello foo" > foo
echo "hello bar" > bar
ln -s foo foo2
如果你检查目录的内容,你会发现你可以看到未加密的形式......
ls -l
:~/decrypted$
...在加密目录中,其加密:
cd ~/encrypted
ls -l
:~/encrypted$
4 挂载和卸载 encfs 卷
要卸载加密卷,请运行:
cd
fusermount -u ~/decrypted
检查...的输出
mount
... 和...
df -h
...您将看到不再列出 EncFS 卷。
要再次安装它,请运行
encfs ~/encrypted ~/decrypted
您将被要求输入您之前定义的密码:
[电子邮件受保护]:~$
如果您指定了正确的密码,这会将 ~/encrypted 目录挂载到 ~/decrypted 从那里您可以以未加密的形式访问您的加密数据。如果您忘记密码,您的加密数据就会丢失!
5 修改encfs密码
如果要更改密码,可以使用
encfsctl passwd ~/encrypted
命令。
[email :~$encfsctl passwd ~/encrypted
输入当前 Encfs 密码
EncFS 密码:<-- yoursecretpassword
输入新 Encfs 密码
新 Encfs 密码:<-- newsecretpassword
验证 Encfs 密码:<-- newsecretpassword
音量密钥已成功更新。
6个链接
- EncFS:http://www.arg0.net/encfs
- Debian:http://www.debian.org/