Encrypted Home directory not auto mounting

Solution 1:

Okay, so while it's possible to use SSH Public Key authentication to log into your system without entering a password (even if your home directory is encrypted), it's not possible to automatically mount your encrypted home directory.

To solve this, you'll need to add a line to the end of your unmounted $HOME/.profile:

ecryptfs-mount-private

This will ensure that after you've logged in using SSH Public Key authentication, you'll be prompted for your password and will mount your encrypted data. If it's already mounted, then this command should just silently succeed.

Enjoy!

Full disclosure: I'm one of the authors and maintainers of eCryptfs.

Solution 2:

Try the following:

  1. Make sure that /etc/pam.d/common-session contains this line:

     # Encrypt home
     session    optional    pam_ecryptfs.so unwrap
    
  2. Make sure that /etc/pam.d/common-auth contains this line:

     auth   optional    pam_ecryptfs.so unwrap
    
  3. Make sure that /etc/pam.d/sshd contains these lines:

     # Standard Un*x authorization.
     @include common-account
    
     # Standard Un*x session setup and teardown.
     @include common-session
    
  4. If you have changed your user's password recently, check /etc/pam.d/common-password

    If it doesn't contain this line:

     password   optional    pam_ecryptfs.so
    

    Then you need your old password to reconfigure ecryptfs.

    My suggestion is to change your account to your previous password using passwd and then adding the above line to /etc/pam.d/common-password and then changing the password back to the new password.

    Alternatively you can try this:

    ecryptfs-setup-private

    Make sure you enter the same password as your users password when prompted.

  5. If none of the above works, try running ecryptfs-setup-private perhaps it will fix something.

  6. If it is still not working then I am out of ideas, sorry.

Solution 3:

By following these instructions you mentioned in your post, you specifically made it so you could SSH into your account without your home folder being mounted. If you undo what you did there and put it back to how it was before, then when you SSH in you will be forced to enter your password if your home directory isn't decrypted already. (If your home directory is already decrypted because of another session, then your SSH key will work perfectly for a passwordless connection!)

Otherwise, the alternative is to run ecryptfs-mount-private after you log in with your key to manually decrypt your home folder.