Linux – How to recover encrypted /home/ folder in Linux Mint 17.2

disk-encryptionlinux-mintpassword

The issue:
I changed my password earlier today, but I must've made a typo, because I couldn't log in afterwards. I booted into the Grub menu and started a passwordless root shell to reset my password. This was successful, as I could now enter the new new password and get past the login screen. However, as soon as I do that, I get an error that says:

Your session only lasted less than 10 seconds. If you have not logged out yourself, this could mean there is some installation problem, or that you may be out of diskspace. Try logging in with one of the failsafe sessions to see if you can fix this problem.

syndaemon: no process found
/etc/mdm/Xsession: Beginning session setup...
localuser:[username] being added to access control list
Can't create dir /home/[username]/Desktop
Can't create dir /home/[username]/Downloads
Can't create dir /home/[username]/Templates
Can't create dir /home/[username]/Public
Can't create dir /home/[username]/Documents
Can't create dir /home/[username]/Music
Can't create dir /home/[username]/Pictures
Can't create dir /home/[username]/Videos
Script for none started at run_im
Script for auto started at run_im
Script for default started at run_im
init: session.migration main process (2322)terminated with status 1
init: logrotate main process (2304) killed by TERM signal
init: Disconnected from notified D-Bus bus

I have the option to hit 'OK' which will take me back to the login screen. If I try to login again, I get the exact same message.

Note: where it says [username] in the above text, the actual error displayed my actual username. I am, however, paranoid when it comes to my online identity, hence I censored it in the error printed above.

I have tried:

  • rebooting the computer, both using a hard boot and using the shut down button on the login screen
  • booting in recovery mode and running 'fix broken packages' and 'check all files' (possibly 'all directories', I can't remember)
  • I have googled and searched every knowledge base I know off, but haven't found a fix
  • I asked at linuxquestions.org
  • Tried deleting and recreating my account with the same username
  • Also;
    I've just tried to use the command line to access my encrypted files, but failed miserably

     mint@mint ~ $  ecryptfs-mount-private
     ERROR: Encrypted private directory is not setup properly
    

    Also also

    mint@mint ~ $ ecryptfs-unwrap-passphrase /media/34e5c4fa-0621-46cb-83b0-763c2a0dc49c/home/.private/[username]/.ecryptfs/wrapped-passphrase
    Passphrase: 
    Error: Unwrapping passphrase failed [-2]
    Info: Check the system log for more information from libecryptfs
    

    It's not related to Disk space (I'm trying to get into the largest drive, on the bottom):

    mint@mint ~ $ df
    df: ‘/root/.gvfs’: Permission denied
    Filesystem                1K-blocks      Used Available Use% Mounted on
    /cow                        2032928   1676256    250076  88% /
    udev                        1979616         4   1979612   1% /dev
    tmpfs                        404796      1552    403244   1% /run
    /dev/sdb1                   3908100   3876388     31712 100% /cdrom
    /dev/loop0                  1523456   1523456         0 100% /rofs
    none                              4         0         4   0% /sys/fs/cgroup
    tmpfs                       2023964        16   2023948   1% /tmp
    none                           5120         0      5120   0% /run/lock
    none                        2023964        84   2023880   1% /run/shm
    none                         102400        28    102372   1% /run/user
    /dev/mapper/mint--vg-root 956884652 103557812 804696876  12% /media/mint/34e5c4fa-0621-46cb-83b0-763c2a0dc49c
    

    Also tried the below. It mounts the files, but doesn't decrypt

    mint@mint ~ $ sudo ecryptfs-recover-private
    INFO: Searching for encrypted private directories (this might take a while)...
    INFO: Found [/media/mint/34e5c4fa-0621-46cb-83b0-763c2a0dc49c/home/.ecryptfs/tijmen/.Private].
    Try to recover this directory? [Y/n]: y
    INFO: Found your wrapped-passphrase
    Do you know your LOGIN passphrase? [Y/n] y
    INFO: Enter your LOGIN passphrase...
    Passphrase: 
    Error: Unwrapping passphrase and inserting into the user session keyring failed [-5]
    Info: Check the system log for more information from libecryptfs
    mint@mint ~ $ sudo ecryptfs-recover-private
    INFO: Searching for encrypted private directories (this might take a while)...
    INFO: Found [/media/mint/34e5c4fa-0621-46cb-83b0-763c2a0dc49c/home/.ecryptfs/tijmen/.Private].
    Try to recover this directory? [Y/n]: y
    INFO: Found your wrapped-passphrase
    Do you know your LOGIN passphrase? [Y/n] n
    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.cQtlJNMc].
    mint@mint ~ $
    

    Other relevant info
    I have Linux Mint 17.2 running on a 1TB external HDD, as my internal HD died months ago. So far, this worked like a charm. I am now using a live USB drive, as I hoped to be able to retrieve some essential files (such as my KeePass database file), but the install on the external HDD is encrypted through the use of the 'encrypt partition' option during install.

    I have been using Linux Mint for about 6-8 months now, so I am somewhat proficient in the use of the terminal for day-to-day use, but I am fully ignorant on the underlying workings of Linux and the root command options at my disposal.

    This is the Linux distro I'm using on the live USB, which is the same one as I've installed on the external HDD

    mint@mint ~ $  cat /etc/*-release
    DISTRIB_ID=LinuxMint
    DISTRIB_RELEASE=17.2
    DISTRIB_CODENAME=rafaela
    DISTRIB_DESCRIPTION="Linux Mint 17.2 Rafaela"
    NAME="Ubuntu"
    VERSION="14.04.2 LTS, Trusty Tahr"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 14.04.2 LTS"
    VERSION_ID="14.04"
    HOME_URL="http://www.ubuntu.com/"
    SUPPORT_URL="http://help.ubuntu.com/"
    BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
    cat: /etc/upstream-release: Is a directory
    

    And this is the kernel
    Linux 3.16.0-38-generic x86_64

    I am able to see all of my folders and files using the live USB, but as they are encrypted, I can't actually access them.

    —- update after first answer —-
    GAD3R suggested I

    Boot using Linux-mint LiveCD
    
    Make sure that your target system's hard drive is mounted
    
    Open a terminal
    
    Install ecryptfs-utils documentation
    
    sudo apt-get install -y ecryptfs-utils
    
    And run
    
    sudo ecryptfs-recover-private
    
    Follow the prompts
    

    Unfortunately, that didn't work.

    mint@mint ~ $ sudo apt-get install -y ecryptfs-utils
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    ecryptfs-utils is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 326 not upgraded.
    mint@mint ~ $ sudo ecryptfs-recover-private
    INFO: Searching for encrypted private directories (this might take a while)...
    INFO: Found [/media/mint/34e5c4fa-0621-46cb-83b0-763c2a0dc49c/home/.ecryptfs/tijmen/.Private].
    Try to recover this directory? [Y/n]: y
    INFO: Found your wrapped-passphrase
    Do you know your LOGIN passphrase? [Y/n] y
    INFO: Enter your LOGIN passphrase...
    Passphrase: 
    Error: Unwrapping passphrase and inserting into the user session keyring failed [-5]
    Info: Check the system log for more information from libecryptfs
    mint@mint ~ $ 
    

    Best Answer

    Boot using Linux-mint LiveCD

    Make sure that your target system's hard drive is mounted

    Open a terminal

    Install ecryptfs-utils documentation

    sudo apt-get install -y ecryptfs-utils
    

    And run

    sudo ecryptfs-recover-private
    

    Follow the prompts

    Access your decrypted data and save somewhere else

    you can also launch the graphical file browser with sudo nautilus and navigate to the temporary directory

    Related Question