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 
  • Which 3rd party tool are you using?
    – nohillside
    Oct 24, 2012 at 17:38
  • I am investigating on behalf of Jettison (google it). Me and them try to figure a way to remount a samba drive, that fails because of being pass protected.
    – SNEILΛ
    Oct 25, 2012 at 6:30
  • You could check out mount_smbfs, assuming that your network shares are smbfs/cifs. mount_smbfs [-N] [-o options] [-d mode] [-f mode] [-h] //[domain;][user[:password]@]server[/share] path I'm not intimately familiar with the OSX startup process, but it's possible you can create your shell-script as a program/folder in /Library/StartupItems or /System/Library/StartupItems source: stackoverflow.com/questions/1142286/…
    – konqui
    Dec 14, 2013 at 7:43

2 Answers 2


Here's how I did it

mkdir -p /Volumes/work && mount \
  -t smbfs \
  //smb-user:$(security find-internet-password -D "Network Password" -l "share name" -w)@server/work \

Eventually it might be required to enable the creation of sub-directories in /Volumes as well. This answer helped me. That means adding 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 I was missing was the capitals when specifying the secret kind.

Wrapping all this in a shell script:



if ! grep -q "user:${current_user} allow add_subdirectory" <<< $(command ls -led /Volumes); then
    echo "Adding \"${current_user}:allow:add_subdirectory\" ACLs to /Volumes"
    sudo chmod +a "${current_user}:allow:add_subdirectory" /Volumes

pass=$(security find-internet-password -D "Network Password" -l "Name-Of-The-Share-In-KeyChain" -w)
[ -z "$pass" ] && echo "pass not found" && exit 1

# TODO find user in keypass
function mount_share() {
    local share_ip=$1
    local share_name=$2 
    mkdir -p /Volumes/${share_name} && mount -t smbfs //smb-user:${pass}@${share_name} /Volumes/${share_name}

mount_share work1
mount_share work2
mount_share work3
mount_share work4
  • Well done connecting the dots and flushing out the syntax!
    – bmike
    Dec 31, 2019 at 15:16

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.

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.

  • i was aware of the "security" command, but i do not know how to set up a temp variable and add it to the command line. I guess that is more linux related that i can handle.
    – SNEILΛ
    Oct 25, 2012 at 6:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .