I have a series of SMB shares that I mount manually when I'm at the office and I had written a helper script that used the OS X
open command to mount the file systems. This worked fine and the credentials were stored in the Key Chain to no further action was required. However the open command then open a new OS X Finder window and destroyed my command line fu -- I had to flip back to my iTerm2 window which was irritating me each time.
The alternative was to use the mount command, which was documented to support a
-N option to read credentials from
~/Library/Preferences/nsmb.conf. However I could not get this to work and it appears that many other people had problems.
It is easy to use the mount command and supply the credentials as follows
mount -t smbfs //$user:$password@$server/$sharename /Volumes/$sharename
With the appropriate values and the
/Volumes/$sharename directory already created. So I wipped up a quick script so make it all automatic.