Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Afuse sshfs automounter (/usr/sbin/mount.afuse)
# afuse-sshfs mount helper to automatically mount remote machines.
# It is intended to be used as mount.afuse in command line. F.e. in /etc/fstab you may mount directory like:
# afuse# /mnt/remote afuse auto 0 0
# And then as regular user just do:
# $ cd /mnt/remote/
# and folder /mnt/remote/ will be mounted automatically!
# On Mac some also recommend add defer_permissions,noappledouble mount options.
# Mount under user and group which are owners of mount point
su -l $( ls -dl "$2" | cut -d' ' -f3) -c "afuse -o mount_template='sshfs -o reconnect -o auto_cache -o kernel_cache %r:/ %m' -o unmount_template='fusermount -u -z %m' -o auto_unmount '$2'"
Copy link

Hubbitus commented Feb 11, 2017

Habrahabr post on Russian about this gist file helper:

Copy link

vonpupp commented Mar 4, 2019

@Hubbitus, who should the the owner and group of the /mnt/remote folder? Do you use a group for the users that are able to use afuse? Thanks.

Copy link

Hubbitus commented Aug 8, 2021

@vonpupp, user, who will use it. Automount script will automatically get owner user from directory and run mount under he.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment