Mounting msdos USB with permissions on OSX

This article was published 4 years ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

This was a fun one. I have my SSH keys on an external disk, but OSX insisted on mounting it as 0777 which meant that SSH didn’t want to read my keys. I couldn’t use umask to change the mount permissions as it’s an msdos USB stick.

Thanks to a combination of symlinks and bindfs, I have it working now.

How to fix:

# Install bindfs
brew install homebrew/fuse/bindfs
# Write aliases to mount/unmount (in .zshrc for me)
unlock () {
    bindfs -n -p 0700 -u $(id -u) -g $(id -g) /Volumes/DATASHUR ~/lockbox
    echo "Unlocked"
}
lock () {
    umount ~/lockbox
    echo "Locked"
}

# Mount the fs
unlock

# Create my symlinks
ln -s /Users/michael/lockbox/keys/ssh .ssh
ln -s /Users/michael/lockbox/keys/ssh/.ssh-ident .ssh-ident

# Now it works!
$ ssh
Loading keys:
    /Users/michael/.ssh/identities/personal/id_rsa
Enter passphrase for /Users/michael/.ssh/identities/personal/id_rsa:

Thoughts on this post

Leave a comment?