Skip to content

Instantly share code, notes, and snippets.

@Hubbitus
Created February 11, 2017 15:00
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Hubbitus/c40d986921cbed6a8ad585eee00a7d77 to your computer and use it in GitHub Desktop.
Save Hubbitus/c40d986921cbed6a8ad585eee00a7d77 to your computer and use it in GitHub Desktop.
Afuse sshfs automounter (/usr/sbin/mount.afuse)
#!/bin/bash
# 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/user@remote.host/remote/path
# and folder /mnt/remote/user@remote.host 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'"
@Hubbitus
Copy link
Author

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