Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm using FileVault to encrypt my homedir. But when I'm not logged (locally) into my remote machine and I'm connecting to it trough SSH my home contains only the sparsebundle file.

How can I mount it so my home dir appears normally as a local login on the machine ?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

Mount

SSH lets you create a ~/.ssh/rc that will be executed right after the environment has been set up, but before any shell will be active (so beware of that; search for "sshrc" in man ssh(8) for more informations).

So, to mount your FileVault partition you can add this line to your ~/.ssh/rc file:

hdiutil attach /Users/$USER/$USER.sparsebundle -mountpoint /Users/$USER

Don't worry, your ~/.ssh/rc will be available to the system even before mounting the FileVault partition.

Unmount

Now you have to ensure the unmount at logout, and only if you are connected via ssh. To do that you can use your shell's logout script. These are the logout script paths for the 3 most used shells on Macs (feel free to add more in the comments):

  • bash: ~/.bash_logout
  • zsh: ~/.zlogout
  • (t)csh: ~/.logout

Open (or create) the appropriate file and add:

if [[ -n $SSH_CONNECTION ]]
    then hdiutil detach /Users/$USER/$USER.sparsebundle
fi
share|improve this answer
    
I read this answer with interest alongside answers under a question in Super User, Mounting a FileVault 2 encrypted external Home Drive at boot with OS X Lion –  Graham Perrin Aug 12 '11 at 6:06
    
I don't know how hdiutil detach would work as written since it's hidden by the mounted partition. Even if I specify /Users/$USER instead, I get "Permission Denied" or "Resource Busy". Suggestions? –  huyz Sep 11 '13 at 23:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.