Mount a samba drive, with password from keychain
Here's how I did it
mkdir -p /Volumes/work \
&& mount -t smbfs //admin:$(security find-internet-password -D "Network Password" -l "share name" -w)@server/work /Volumes/work
Eventually creating sub-directory in /Volumes
may require the add_subdirectory
permissions, eg
sudo chmod +a "$(whoami):allow:add_subdirectory" /Volumes
The keychain access was a bit tricky, I found the answer and wrote it there. The important part was the capitals when specifying the secret kind.
You'll need to be able to create directories in /Volumes
as well. This answer helped me.
There is a script able interface to the keychain and it is the security
command.
If you are handy with shell scripting or another language and the password doesn't have spaces and odd characters you need to handle, you could follow this tutorial and teach yourself enough to get the password out of the keychain.
- http://blog.macromates.com/2006/keychain-access-from-shell/
So once you've figured out how to pass the password in as a command line argument user:pass
you could execute the security command inline or set a temporary variable to hold the value.