Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using encfs to encrypt my dropbox contents and for that reason I'd like to have encfs mounted when users log in rather than at system startup. However, I can't make this work. I've tried:

  • Adding the mount command to .login/.profile. This doesn't work, because these scripts are executed when a shell starts up, not when the user logs in normally.
  • Adding a LoginHook to This doesn't do anything except slow down my login process. There is nothing in the system log files, so I'm not sure how to debug this.
  • I took a look at /etc/fstab, but on Mountain Lion that file is empty, except for the warning that this file has no effect whatsoever, so adding anything to it won't help.

For those not familiar with encfs, but familiar with getting stuff done on OSX, essentially what I have to run to mount the encrypted filesystem is this command:

echo password | encfs -S encrypted_dir mount_point

Any help at all appreciated.

share|improve this question
I'd like to point out that it's a bad idea to keep that password in your startup script. Instead you can keep it in your keychain. See Eg: encfs --ondemand --extpass="security 2>&1 >/dev/null find-generic-password -gl encfs | grep password | cut -d \\\" -f 2" encrypted_dir unencrypted_mount_dir – nilbus Sep 25 '13 at 19:06
up vote 1 down vote accepted

You can run any executable at login (including scripts) by adding it via System Preferences -> Users & Groups -> Login Items. Do not give the script an extension; use a name like foo not Since there's no associated window to display error messages if something goes wrong, I advise redirecting stdout and stderr into a file in /tmp.

share|improve this answer
This works great, thanks. One more thing, though. When the script is run, briefly a terminal window pops up and then disappears when the script is finished. That's not a big deal, but kinda goes against my sense to tidyness. Can I avoid that popup somehow? – Jochen Aug 14 '12 at 2:29
I don't know any way around it. – Kyle Jones Aug 14 '12 at 3:09

The proper way to do this is to create a launchctl service. You won't have any Terminal windows open at login.

Create a script /usr/local/bin/encfs-mount to load encfs with the arguments you desire. This would be similar to the script you're already loading. For example:

/usr/local/bin/encfs -f --ondemand --extpass="security 2>&1 >/dev/null find-generic-password -gl encfs | grep password | cut -d \\\" -f 2" -i 15 ~/.sync ~/sync

Note that the above script uses the OSX Keychain via the security command to provide the password, rather than saving it in this script. To add the password, open the Keychain Access tool, and add an application named encfs to one of your keychains. Use your login keychain if you never want to be prompted for the password, the System keychain if you want to be prompted for the encfs password every time it mounts the filesystem with --ondemand, or a new keychain if you want it to have its own password. See

Create a service file at ~/Library/LaunchAgents/com.arg0.encfs.plist to load that script. Replace YOUR_USERNAME with your username:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Be sure encfs is not already running (if not, unmount and stop it). Then start the new service:

launchctl load ~/Library/LaunchAgents/com.arg0.encfs.plist

Your encfs filesystem should mount. Check /var/log/system.log to troubleshoot.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .