I'm maintaining a heterogeneous network of mac and linux so I decided to create a little perl script to unify mounting strategies across machines.
Actually, I already have a working perl script, however, the password seems is part of the command line which I don't like:
mount_smbfs -d 755 -f 755 //username_here:[email protected]/cifs_share
Tried reading the man pages for mount_smbfs and nsmb.conf but I am still confused as to how to move forward.
My machines are Snow Leopard, Leopard and Lion machine.
A more secure solution than that proposed by SvenW, and one that is more in keeping with the Apple way of doing things, is to add the password to the keychain. Here's how you would do it for an AFP share (I assume all you'd need to do is change the protocol specified by the -r option but I don't have the possibility of testing this with SMB right now; note that the whitespace in "afp " is intentional and necessary and I've only used this in a 10.6 environment):
Here's the relevant part of the man page for the security command:
The same thing should work for an SMB share, but note that the mechanism for matching keychain entries is quite particular (e.g. requiring that odd whitespace in the protocol name), so you need to test and be precise about how you store the password. When I first used this approach, I found that in order to get the paramaters right, it helped to first create the password in the keychain via the GUI (i.e. mount the share in the Finder and tick the box to save the authentication credentials to the keychain) and work backwards by examining the resulting entry in the keychain.
As noted by SvenW, the keychain needs to be unlocked for this approach to work, but that should happen automatically when the user logs in and should not be a problem based on your description. I'd also like to confirm that Kerberos does indeed work in 10.5 and 10.6 but is problematic in 10.7.
Put a ~/Library/Preferences/nsmb.conf file with the following content into the home directory of the user you want to do the mount:
After that, you can simply do
For me, it was a matter of looking at what was IN my keychain…
and matching that up with my
auto_smb
map.../../Volumes/ServiceData -fstype=smbfs,soft ://home._smb._tcp.local/ServiceData
The answer about the
~/Library/Preferences/nsmb.conf
file was almost correct. You probably need to use the-N
flag. From themount_smbfs
man page: