Reconstructing a deleted encrypted home directory after mistakenly removing .ecryptfs and .Private directories is a challenging process. The successful recovery depends heavily on the availability of critical metadata files like the wrapped-passphrase and Private.sig.
I’ll break this down step by step to address your questions.
The essential directory structure for an encrypted home directory looks like this:
/home/.ecryptfs/username/
├── .ecryptfs
│ ├── Private.mnt # Mount point metadata
│ ├── Private.sig # Signature of the wrapped passphrase
│ ├── wrapped-passphrase # Encrypted version of your mount passphrase
│ └── ... other metadata files
└── .Private
├── (Encrypted files with random names)
└── ... other files
.Private directory: Contains encrypted user files. These files have random alphanumeric names and are encrypted..ecryptfs directory: Contains metadata needed to decrypt and mount the .Private directory.If you recovered files with .ecryptfs extensions and random filenames, they likely belong to both .ecryptfs and .Private. We need to separate these files correctly.
Here are the critical files and how to identify/reconstruct them:
wrapped-passphrase:
What to do:
wrapped-passphrase. It is typically found in the /home/.ecryptfs/username/.ecryptfs/ directory.Private.sig:
What to do:
Private.sig. If found, place it in /home/.ecryptfs/username/.ecryptfs/.Private.mnt:
What to do:
Private.mnt. If found, place it in /home/.ecryptfs/username/.ecryptfs/.Since you recovered a mix of files, including ones with random names, you need to manually sort and identify the critical metadata files.
Use the grep command to identify files containing recognizable patterns:
grep -rl 'ENCRYPTION' /path/to/recovered_files
Search specifically for wrapped-passphrase and Private.sig:
find /path/to/recovered_files -type f -name '*wrapped-passphrase*'
find /path/to/recovered_files -type f -name '*Private.sig*'
Look for small files (a few kilobytes in size), as these are likely metadata files:
find /path/to/recovered_files -type f -size -10k
If you’ve found the critical files:
Place the files in the correct directories:
/home/.ecryptfs/username/.ecryptfs/wrapped-passphrase
/home/.ecryptfs/username/.ecryptfs/Private.sig
/home/.ecryptfs/username/.ecryptfs/Private.mnt
Place the encrypted files (random names) in:
/home/.ecryptfs/username/.Private/
Once the directory structure is restored, try the following steps to mount the directory:
If you have the wrapped-passphrase file, you can unwrap it using your login password:
ecryptfs-unwrap-passphrase /home/.ecryptfs/username/.ecryptfs/wrapped-passphrase
You’ll need to provide your login password. The output will be your mount passphrase (a 32-character hexadecimal string).
Once you have the mount passphrase:
sudo mount -t ecryptfs /home/.ecryptfs/username/.Private /home/username \
-o ecryptfs_sig=<signature>,ecryptfs_fnek_sig=<signature>,ecryptfs_key_bytes=16,ecryptfs_cipher=aes,ecryptfs_passthrough=no,ecryptfs_enable_filename_crypto=yes
<signature> with the signature found in Private.sig./home/username with your actual mount point.If you do not have the wrapped-passphrase file, recovery becomes very difficult because the encrypted files cannot be decrypted without the mount passphrase.
The options are:
PhotoRec or testdisk.If you need to stop and retry, always ensure the following directories have the correct permissions:
sudo chown -R username:username /home/.ecryptfs/username
wrapped-passphrase, Private.sig, and Private.mnt./home/.ecryptfs/username/.ecryptfs//home/.ecryptfs/username/.Private/wrapped-passphrase is available) and mount the directory manually.wrapped-passphrase is missing, recovery is unlikely without an external backup.If you face issues at any step, please share the output of the relevant commands, and I’ll assist further.