MacOS – Automount SMB using keychain password

automountkeychainmacosnassmb

Is there a way to use the automount service to mount my NAS share but without specifying my password in my SMB path?

Currently, I have the following:

/etc/auto_master

#
# Automounter master map
#
+auto_master            # Use directory service
/net                    -hosts          -nobrowse,hidefromfinder,nosuid
/home                   auto_home       -nobrowse,hidefromfinder
/Network/Servers        -fstab
/-                      -static
/Volumes/NAS1           auto_nas

/etc/auto_nas

home    -fstype=smbfs,soft smb://ericb:mypassword@NAS1/home

But I would like to remove "mypassword" from the config file and have automount use the data stored in the keychain.

Is this possible?

Best Answer

  • A litte late answer but i've made a small script which provides what you need, take a look at https://github.com/gniemetz/automount, it's self explanatory

    How does it work:
    After logging in a LaunchAgent starts the script /usr/local/bin/automount.sh, which then parses the file ~/Library/Preferences/it.niemetz.automount.plist. It then tries to mount the given shares (afp/smb/webdav supported) and gives the user a notification when it's done.
    For security reasons all the needed passwords are fetched from the login keychain of the user, so no password is stored in the script

  • Related Question