업그레이드가 중단된 후 비밀번호를 사용하여 ecryptfs 암호화된 데이터를 복구하는 방법은 무엇입니까?

업그레이드가 중단된 후 비밀번호를 사용하여 ecryptfs 암호화된 데이터를 복구하는 방법은 무엇입니까?

나는 최근에 급락하여 14.04에서 16.04로의 업그레이드를 수락했습니다. 패키지를 설치하는 동안 컴퓨터를 떠났는데, 다시 컴퓨터로 돌아왔을 때 커서 하나만 깜박이는 검은색 화면이 나타났습니다.

재설정하면서 나는 결론에 도달했습니다.지루하다고칠 가치가 있는 것 이상입니다.

암호화된 데이터를 복구하는 방법은 무엇입니까?

답변1

어떻게 고쳤습니까?

우분투 설치 프로그램을 실행하고 루트 파티션을 지웠습니다. 새로운 새로 설치는 이전 설치보다 훨씬 더 건강한 느낌을 주므로 어쨌든 필요할 것입니다.

처음 로그인할 때 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내가 얻은 것을 사용하여하지만 불행하게도 파일을 인수로 제공하지 않았을 때 얻은 것과 동일했기 때문에 이전 데이터에 대한 키가 아닌 현재 키만 얻은 것 같습니다.

이전 파일과 새 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-file은 내 로그인 비밀번호를 사용하여 암호화되므로 해당 파일이 있고 내 비밀번호를 알고 있는 한 내 데이터에 액세스할 수 있습니다.

더 건전한 경로/키 조합을 사용해도 불행하게도 큰 차이가 나지 않았습니다.

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을 통해?).

라이브 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로그인 비밀번호를 사용하여 난독화됩니다. 비밀번호를 알고 파일이 있는 경우 실제 KEY 인쇄물이 필요하지 않습니다.

글이 길어서 죄송합니다. 여기 있는 제 "일기"를 통해 다른 사람의 시간을 절약할 수 있기를 바랍니다.

관련 정보