Auto-mount with SSH public key authentication

Asked by Simon Sprünker

If I login to my box using SSH and enter my passphrase my ~/Private folder is mounted. However if I use SSH with public key authentication my ~/Private folder is not mounted. Is there a way to accomplish this?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
eCryptfs Edit question
Assignee:
No assignee Edit question
Solved by:
Milan Knizek
Solved:
Last query:
Last reply:
Revision history for this message
Best Milan Knizek (knizek) said :
#1

There are more ways to make it work (e.g. storing the public key somewhere else and changing the /etc/ssh/sshd.conf file), but I have set it up this way:

0. Login as the user with encrypted home directory

1. Create a new directory (replace "yourusername" with your login...)
$ mkdir /var/lib/ecryptfs/yourusername/ssh

2. Copy the public keys to that directory
$ cp ~/.ssh/authorized_keys /var/lib/ecryptfs/yourusername/ssh

3. Create a symlink to the new location
$ ln -sf /var/lib/ecryptfs/yourusername/ssh/authorized_keys ~/.ssh/authorized_keys

4. Make sure the ~/Private directory is unmounted (e.g. logout and login as another user with admin rights or root)

5. Create a symlink in home directory (the directory now shows only few files and .Private)
$ sudo ln -s /var/lib/ecryptfs/yourusername/ssh /home/yourusername/.ssh

The approach is similar to how the directory ~/.ecryptfs works.

Revision history for this message
Simon Sprünker (simons.spruenker) said :
#2

Thanks Milan Knizek, that solved my question.