Mount a samba drive, with password from keychain

keychainmountpasswordsmb

I have a problem with Jettison, that tries to remount a samba drive, that is protected by a password.

It uses the following command line:

/sbin/mount_smbfs //[user]@[server]/work /Volumes/work 

Of course it fails since the password is not present (nor the -N switch)

I am aware that it should contain a password, but I do not want the app to know it. So my question is:

Is there a way to request the password like this (I am aware this is not correct):

/sbin/mount_smbfs //[user]: %keychain->[identified keychain]%@<server>/work /Volumes/work 

Best Answer

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

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.