答案1
我如何修复它:
我启动了 ubuntu 安装程序并清除了我的根分区。新安装比旧安装感觉好得多,所以无论如何都是必要的。
首次登录时,我收到一条提醒,将我的 ecryptfs 密钥保存在安全的地方 -我不记得上次安装时做过这个。
当我组装我的主文件夹阵列时,我发现了我认为是我的加密数据:
root@computer:~/mnt/user# ls -la
total 8
dr-x------ 2 user user 4096 jul 2 2011 .
drwxr-xr-x 8 root root 4096 feb 18 2015 ..
lrwxrwxrwx 1 user user 56 jul 2 2011 Access-Your-Private-Data.desktop -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.desktop
lrwxrwxrwx 1 user user 33 jul 2 2011 .ecryptfs -> /home/.ecryptfs/user/.ecryptfs
lrwxrwxrwx 1 user user 32 jul 2 2011 .Private -> /home/.ecryptfs/user/.Private
lrwxrwxrwx 1 user user 52 jul 2 2011 README.txt -> /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt
但我无法解锁它。
root@computer:~# ecryptfs-unwrap-passphrase /root/mnt/user/.ecryptfs/wrapped
Passphrase:
ffffffffffffffffffffffffffffffff
root@computer:~# ecryptfs-recover-private /root/mnt/user
INFO: Found [/root/mnt/user].
Try to recover this directory? [Y/n]:
INFO: Could not find your wrapped passphrase file.
INFO: To recover this directory, you MUST have your original MOUNT passphras
INFO: When you first setup your encrypted private directory, you were told t
INFO: your MOUNT passphrase.
INFO: It should be 32 characters long, consisting of [0-9] and [a-f].
Enter your MOUNT passphrase:
INFO: Success! Private data mounted at [/tmp/ecryptfs.lls9FwPj].
root@computer:~# ls -la /tmp/ecryptfs.lls9FwPj
total 8
dr-x------ 2 user user 4096 Jul 2 2011 .
drwxrwxrwt 11 root root 4096 Sep 11 11:08 ..
lrwxrwxrwx 1 user user 32 Jul 2 2011 .Private -> /home/.ecryptfs/user/.
lrwxrwxrwx 1 user user 33 Jul 2 2011 .ecryptfs -> /home/.ecryptfs/user/
lrwxrwxrwx 1 user user 56 Jul 2 2011 Access-Your-Private-Data.desktop -
lrwxrwxrwx 1 user user 52 Jul 2 2011 README.txt -> /usr/share/ecryptfs-
没有错误,但挂载点仅包含与源文件夹相同的未加密数据。
使用ecryptfs-unwrap-passphrase /root/mnt/user/.ecryptfs/wrapped-passphrase
我确实得到了A密钥,但不幸的是,如果我不提供文件作为参数,它与我得到的密钥相同,所以我想我只得到了我当前的密钥,而不是旧数据的密钥。
似乎新旧wrapped-passphrase
文件相同:
root@computer:~# mount | grep md0
/dev/md0 on /root/mnt type ext4 (rw,relatime,data=ordered)
root@computer:~# md5sum /home/user/.ecryptfs/wrapped-passphrase /root/mnt/user/.ecryptfs/wrapped-passphrase
52da6f1ea1ffff114795c7613b5c560e /home/user/.ecryptfs/wrapped-passphrase
52da6f1ea1ffff114795c7613b5c560e /root/mnt/user/.ecryptfs/wrapped-passphrase
我发现这很奇怪,因为md0
在安装时甚至没有组装。
然而,通过仔细阅读,我终于解开了这个谜团:
root@computer:~# ls -l /root/mnt/user/.Private
lrwxrwxrwx 1 user user 32 Jul 2 2011 /root/mnt/user/.Private -> /home/.ecryptfs/user/.Private
似乎我一直在对新的主文件夹而不是旧数据的符号链接进行操作。
读取正确的文件给出了另一个(正确的)密钥!
root@computer:~/mnt/.ecryptfs/user# ecryptfs-unwrap-passphrase /root/mnt/.ecryptfs/user/.ecryptfs/wrapped-passphrase
Passphrase:
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
这实际上是我最初问题的答案:该wrapped-passphrase
文件使用我的登录密码加密,因此只要我有该文件并知道我的密码,我就应该能够访问我的数据。
不幸的是,使用更合理的路径/组合键并没有带来太大的差别:
root@computer:~/mnt/.ecryptfs/user# ls -al
total 52
drwxr-xr-x 4 user user 4096 Jul 2 2011 .
drwxr-xr-x 3 root root 4096 Jul 2 2011 ..
drwxr-xr-x 121 user user 36864 Sep 8 14:58 .Private
drwx------ 2 user user 4096 Mar 15 2015 .ecryptfs
root@computer:~/mnt/.ecryptfs/user# ecryptfs-recover-private /root/mnt/.ecryptfs/user
INFO: Found [/root/mnt/.ecryptfs/user].
Try to recover this directory? [Y/n]:
INFO: Could not find your wrapped passphrase file.
INFO: To recover this directory, you MUST have your original MOUNT passphrase.
INFO: When you first setup your encrypted private directory, you were told to record
INFO: your MOUNT passphrase.
INFO: It should be 32 characters long, consisting of [0-9] and [a-f].
Enter your MOUNT passphrase:
INFO: Success! Private data mounted at [/tmp/ecryptfs.dKQkSvjC].
root@computer:~/mnt/.ecryptfs/user# ls -al /tmp/ecryptfs.dKQkSvjC
total 52
drwxr-xr-x 4 user user 4096 Jul 2 2011 .
drwxrwxrwt 12 root root 4096 Sep 11 12:32 ..
drwxr-xr-x 121 user user 36864 Sep 8 14:58 .Private
drwx------ 2 user user 4096 Mar 15 2015 .ecryptfs
由于一些 ecryptfs-tools 有硬编码路径,我甚至尝试过:
root@computer:~# mount /dev/md0 /home
root@computer:~# su - user
Signature not found in user keyring
Perhaps try the interactive 'ecryptfs-mount-private'
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
user@computer:~$ ecryptfs-mount-private
Enter your login passphrase:
Inserted auth tok with sig [e403598bcfe01170] into the user session keyring
mount: No such file or directory
但那里也没有雪茄。
做同样的事情沒有但是安装md0
也/home
不起作用。
user@computer:~$ dash -e -x `which ecryptfs-mount-private`
+ PRIVATE_DIR=Private
+ WRAPPING_PASS=LOGIN
+ PW_ATTEMPTS=3
+ TEXTDOMAIN=ecryptfs-utils
+ gettext Enter your login passphrase:
+ MESSAGE=Enter your login passphrase:
+ [ -f /home/user/.ecryptfs/wrapping-independent ]
+ WRAPPED_PASSPHRASE_FILE=/home/user/.ecryptfs/wrapped-passphrase
+ MOUNT_PASSPHRASE_SIG_FILE=/home/user/.ecryptfs/Private.sig
+ /sbin/mount.ecryptfs_private
+ [ -f /home/user/.ecryptfs/wrapped-passphrase -a -f /home/user/.ecryptfs/Private.sig ]
+ tries=0
+ stty -g
+ stty_orig=2d00:5:bd:ca1b:3:1c:7f:1f:4:0:1:0:11:13:1a:ff:12:f:17:16:ff:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
+ [ 0 -lt 3 ]
+ echo -n Enter your login passphrase:
Enter your login passphrase:+ stty -echo
+ head -n1
+ LOGINPASS=MyLoginPassword
+ stty 2d00:5:bd:ca1b:3:1c:7f:1f:4:0:1:0:11:13:1a:ff:12:f:17:16:ff:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
+ echo
+ wc -l
+ [ 2 = 1 ]
+ printf %s\0 MyLoginPassword
+ ecryptfs-insert-wrapped-passphrase-into-keyring /home/user/.ecryptfs/wrapped-passphrase -
Inserted auth tok with sig [93196f7a8af1fdfe] into the user session keyring
+ break
+ [ 0 -ge 3 ]
+ /sbin/mount.ecryptfs_private
mount: No such file or directory
user@computer:~$ ls -l /sbin/mount.ecryptfs*
-rwxr-xr-x 1 root root 25944 jul 13 19:13 /sbin/mount.ecryptfs
-rwsr-xr-x 1 root root 19024 jul 13 19:13 /sbin/mount.ecryptfs_private
因此,在正常登录期间可能发生了一些神奇的事情(通过 PAM?),而我的示例中却没有出现这些神奇的事情。
启动 live-cd 我就能访问数据了!
root@ubuntu:~# apt install mdadm
Reading package lists... Done
[...]
root@ubuntu:~# mdadm --assemble /dev/md0 /dev/sd[bc]1
mdadm: /dev/md0 has been started with 2 drives.
root@ubuntu:~# mount /dev/md0 /home
root@ubuntu:/home# ecryptfs-recover-private /home/.ecryptfs/user/.PrivateINFO: Found [/home/.ecryptfs/user/.Private].
Try to recover this directory? [Y/n]:
INFO: Found your wrapped-passphrase
Do you know your LOGIN passphrase? [Y/n] Y
INFO: Enter your LOGIN passphrase...
Passphrase:
Inserted auth tok with sig [f403498bcfd01070] into the user session keyring
INFO: Success! Private data mounted at [/tmp/ecryptfs.uHQ0z177].
root@ubuntu:/home# ls /tmp/ecryptfs.uHQ0z177/ | grep Doc
Documents
但即便如此,这些工具的效果也并不完美:
root@ubuntu:/home# ecryptfs-recover-private
INFO: Searching for encrypted private directories (this might take a while)...
find: ‘/run/user/999/gvfs’: Permission denied
find: File system loop detected; ‘/sys/kernel/debug/pinctrl’ is part of the same file system loop as ‘/sys/kernel/debug’.
所以我开始认为我遇到的大多数问题只是 ecryptfs 在可用性方面有待改进。
重新启动进入我的真实安装我现在可以访问数据:
root@computer:~# mount /dev/md0 mnt
root@computer:~/mnt/.ecryptfs/user/.Private# cd /root/mnt/.ecryptfs/user/.Private/
root@computer:~/mnt/.ecryptfs/user/.Private# ecryptfs-recover-private .
INFO: Found [.].
Try to recover this directory? [Y/n]:
INFO: Found your wrapped-passphrase
Do you know your LOGIN passphrase? [Y/n]
INFO: Enter your LOGIN passphrase...
Passphrase:
Inserted auth tok with sig [f4f3498bcfd01070] into the user session keyring
INFO: Success! Private data mounted at [/tmp/ecryptfs.ZMqBVhRu].
root@computer:~/mnt/.ecryptfs/user/.Private# ls /tmp/ecryptfs.ZMqBVhRu | grep Doc
Documents
编辑 :
看来“搜索”工具ecryptfs-recover-private
不太擅长定位.Private
文件夹。提供正确的绝对路径就可以了。
ecryptfs-recover-private
仅在未提供任何参数时进行搜索。如果提供了路径,则必须指向文件.Private
夹。
在此示例中:
ecryptfs-recover-private /root/mnt/.ecryptfs/user/.Private
是的,wrapped-passphrase
使用您的登录密码进行混淆,如果您知道您的密码并拥有文件,您就不需要实际的密钥打印输出。
抱歉,这篇文章太长了,但希望我的“日记”可以为别人节省几个小时。