LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-18-2019, 07:47 PM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
Question Make testdisk read an encrypted home folder


Trying to use testdisk to hopefully recover a stupid delete. Going into the encrypted home folder though, it doesn't show the contents but just a few random things.
I'm sure I'm doing something wrong, just not sure what
 
Old 09-18-2019, 09:03 PM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
well, if the home is encrypted testdisk is only going to see 'random' things

In all honesty I have never played with encrypted filesystems, so I don't know if this will work.

I assume you are currently working with unmounted filesystems

if /home is a partition which is encrypted
take note of
Code:
ls /dev/mapper/
can you decrypt/mount home read only?
If you can you should see new things in /dev/mapper

what you then need to do is run testdisk/photorec on the decrypted blockdevice that appeared. Since it is decrypted testdisk/photorec should be able to see things clearly and be able to recover the deleted file{s}

I am assuming the encryption is on the filesystem and not per file. I imagine per-file would be a whole lot more complicated.

if you can't mount read only
do not login with anything that will write to /home
and make sure you save the deleted files to somewhere that is *not* in /home
 
1 members found this post helpful.
Old 09-19-2019, 01:06 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
For some-one who has been a member that long the question is appallingly short on necessary detail.
What type of encryption - you list RHEL/CentOS, but that sounds like eCryptfs as used on Ubuntu and derivatives. Not LUKS as would be the expected norm for RH.
Be (much) more specific and you might get better replies.
 
Old 09-19-2019, 07:20 AM   #4
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Sorry to offend syg, had a few brief moments of great signal on a train so fired it off when I could, plus didn't have the machine near me. But you were able to correctly surmise it is indeed eCryptfs I'm talking about. I believe the only two files it showed were a read me then one other file that made it sound like it might unencrypt the directory for you. Sorry, still don't have access to the machine.
And as you probably also correctly surmised, my experience with eCryptfs is zero and testdisk is barely above that

Last edited by anon091; 09-19-2019 at 07:22 AM.
 
Old 09-19-2019, 04:39 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,974

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
If you boot to a live media can you access that folder? I don't mean the contents, I mean does the folder show as available to the native filesystem?
 
1 members found this post helpful.
Old 09-19-2019, 05:49 PM   #6
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Hi jefro. I did boot off a Linux mint USB and install testdisk there and was and was able to navigate down to the folder itself. Folder itself also accessible just from a simple mount and clicking through

Last edited by anon091; 09-19-2019 at 05:51 PM.
 
Old 09-19-2019, 06:53 PM   #7
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by rjo98 View Post
Hi jefro. I did boot off a Linux mint USB and install testdisk there and was and was able to navigate down to the folder itself. Folder itself also accessible just from a simple mount and clicking through
I imagine it will be difficult since the deleted file{s} will be just random garbage that testdisk won't be able to parse

or maybe those few random things you found are the files
try recovering those and see if they decrypt

from what I've read ( briefly ) eCryptfs is a filesystem on a filesystem

I guess the folder is like a file that has been treated like a block device and mounted loopback.
so it should end up in /dev/mapper at some point
 
1 members found this post helpful.
Old 09-19-2019, 07:28 PM   #8
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,974

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
"Folder itself also accessible just from a simple mount and clicking through"

I'm guessing here but when you do mount it and you are able to view the current contents then try photorec maybe?

Based on Firerat's suggestion then I can't say if the mounted virtual filesystem will be available to the recovery program or not. Might peek at mount command to see if that encryption mounts while executing it's task.

Last edited by jefro; 09-19-2019 at 07:30 PM.
 
1 members found this post helpful.
Old 09-19-2019, 07:38 PM   #9
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Had access to the machine a bit earlier. Even if I boot to the Linux Mint OS itself, which I can see the data through the GUI and CLI for /home/username, but if i run testdisk or photorec, once i get into /home/username through that, i see actually 5 things but three start with dot: .encryptfs, .Private, README.txt, Access-Your-Private-Data.desktop, and .cache

Whereas if I just do a ls /home/username normally, i see all the "real" stuff like all the dot directories, folders like Desktop, Documents, etc.

Almost seems like I need a way to tell testdisk to use the encryption or what the key is for it, so it can read it maybe? or maybe testdisk just doesn't work on encryptfs home folders.

Worst part is, they had no real reason to encrypt their home folder other than they could
 
Old 09-19-2019, 07:41 PM   #10
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
firerat, missed a question earlier from you i think. in /dev/mapper via testdisk all i see is control, but i don't see the cryptswap1 that i do from a normal ls of it.
 
Old 09-19-2019, 08:18 PM   #11
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
form the eCryptfs manpage

Code:
DESCRIPTION
       eCryptfs  is  a POSIX-compliant enterprise-class stacked cryptographic filesystem for Linux. It is derived from Erez
       Zadok's Cryptfs, implemented through the FiST framework for generating stacked filesystems. eCryptfs extends Cryptfs
       to  provide  advanced  key  management and policy features.  eCryptfs stores cryptographic metadata in the header of
       each file written, so that encrypted files can be copied between hosts; the file will be decryptable with the proper
       key,  and  there  is no need to keep track of any additional information aside from what is already in the encrypted
       file itself. Think of eCryptfs as a sort of "gnupgfs."
from ecryptfs-setup-private manpage

Code:
FILES
       ~/.ecryptfs/auto-mount

       ~/.Private - underlying directory containing encrypted data

       ~/Private - mountpoint containing decrypted data (when mounted)

       ~/.ecryptfs/Private.sig - file containing signature of mountpoint passphrase

       ~/.ecryptfs/Private.mnt - file containing path of the private directory mountpoint

       ~/.ecryptfs/wrapped-passphrase - file containing the mount passphrase, wrapped with the login passphrase

       ~/.ecryptfs/wrapping-independent - this file exists if the wrapping passphrase is independent from login passphrase

so the deleted files *should* be on the "normal" filesystem
photorec lists eCryptfs
https://www.cgsecurity.org/wiki/File...ed_By_PhotoRec

the filenames won't make sense
but they should be under ~/.Private/

it looks like the filename won't matter, as it is all in the metadata
 
1 members found this post helpful.
Old 09-19-2019, 08:30 PM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,120

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Yes, testdisk would seem the wrong tool. Photorec run on free space within that filesystem might do the job - presuming nothing has been written to it in the interim.
 
1 members found this post helpful.
Old 09-20-2019, 07:17 AM   #13
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Ah ha. Will try looking in ~/.Private today both with testdesk and photorec, thanks.
 
Old 09-20-2019, 07:19 AM   #14
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
Quote:
Originally Posted by rjo98 View Post
Ah ha. Will try looking in ~/.Private today both with testdesk and photorec, thanks.
you may need to configure photorec to look for .ecr .ecrfs
( check on the photorec link I gave )
 
Old 09-20-2019, 07:31 AM   #15
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Understood. Have photorec running now with the eCrytpfs option checked (I only saw the one), looks like it's recovering stuff. So now i'll just need to let it run, figure out how to decrypt them, and see if any are what they deleted
thanks for the help!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Store ecryptfs files inside home folder when enabling full home folder encryption in Linux Murz Linux - Security 4 10-27-2018 03:57 AM
What's the best way to make an encrypted folder without encrypting a whole partition? abefroman Linux - Security 6 08-15-2017 11:38 AM
Problems with encrypted home folder after Ubuntu doesn't boot anymore leonlang Ubuntu 1 01-08-2017 08:35 AM
Make a normally read write folder read only with LTSP? jmgibson1981 Linux - Newbie 2 08-09-2016 04:25 AM
Home folder icon does not open home folder CiscoGeek Linux - Newbie 3 12-18-2006 07:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration