SMB mount issues

cgolebio
New Contributor III

Hi all,
Yesterday in Massachusetts we had a Winter storm, so naturally my brain is off by a day; forgive my ignorance if this turns out to be an easy one.

I am trying to mount a share via script. It works initially, then I unmount it and attempt to remount with the script. I get an error saying server refused the connection, authentication error. I try using the Connect to Server GUI, and doesn't work no matter the credentials.

If I leave for a bit (~30 minutes) and come back and try again it works initially again, but any tries directly after again do not work.

Reviewing logs on the file server, if I intentionally type the password wrong into the script it logs an error as expected but is not logging any errors when it is refusing connection using the correct password. This makes me think the SMB client on the Mac is somewhat at fault here.

Note: no Kerberos ticket or keychain entries to contend with.

Here is the syntax I am using:

#!/bin/sh
mkdir /Volumes/sharename
mount -t smbfs //domain;user:pass@server/sharename /Volumes/sharename
#do something
umount /Volumes/sharename

Does anyone have any ideas? If there is a SMB cache or something, how could I appropriately reset this if this is at fault?

9 REPLIES 9

sean
Valued Contributor

Is there a delay on un-mounting?

Eg. after umount /Volumes/sharename is the drive still mounted for a period of time?

df

Has the made directory been removed:

ls -al /Volumes

cgolebio
New Contributor III

Hi Sean
Following umount, the directory has been removed (all that appears is the MacintoshHD and a second partition I have). Running df shows the standard mounts.

sean
Valued Contributor

In that case, does the server still think there is a live connection, since at a basic level it looks like the client doesn't?

cgolebio
New Contributor III

Hi Sean,
I looked at the server while I was mounting the share initially. Everything looks great in the session manager. I unmount, and the session disconnects. So far so good...

I try to reconnect, get the error, nothing in the session manager.

I decided to Wireshark the traffic. Note that it is using SMB2, which I realize may still have issues in El Capitan? I thought this was strange...
On a successful connection, the session flags appear like this:
Session Flags: 0x0000 .... .... .... ...0 = Guest: False .... .... .... ..0. = Null: False

On a unsuccessful connection, the session flags appear like this:
Session Flags: 0x0001, Guest .... .... .... ...1 = Guest: True .... .... .... ..0. = Null: False

Is there a way to force via command line the use of SMB1 without modifying the nmbd.conf file? I am going to try creating and setting the smb_neg value within this file just to test that forcing SMB1 is the answer. Curious how I can implement this via the mount or mount_smbfs command.

cgolebio
New Contributor III

Update: I created and set smb_neg=smb1_only in the nsmb.conf file under ~/Library/Preferences/, and no change. The Windows 2012 server has SMB 1.0/CIFS support enabled, and I can connect this way through the Connect to Server GUI using cifs://servername/sharename. I can connect and disconnect as many times as I want using CIFS. If I use smb://servername/sharename in the Connect to Server GUI, I get same result as if through the command line--not able to connect.

Any help is appreciated getting this to work through the command line.

Thank you ahead of time!

sean
Valued Contributor

Can you provide your whole nsmb.conf file?

cgolebio
New Contributor III

I realized I made a mistake. I wrote the nsmb.conf file to ~/Library/, not ~/Library/Preferences/, my mistake...

Here is the file:

[default]
smb_neg=smb1_only

Once I moved it, I tested the script over and over again, and it worked! Mounting/Unmounting as many times as my heart desires!

So 2 questions:
- Is it possible to set this option via command line? - Otherwise, I can modify the script to check for the file and create it if it doesn't exist. I believe if I write it to /etc/nsmb.conf instead it will apply to all users who log in, is that correct?

davidacland
Honored Contributor II

Not sure if the behaviour would be different but you could try using the osascript mount command. Here's a link to our Casper and non-Casper versions:

https://github.com/amsysuk/public_scripts/tree/master/shareConnect

sean
Valued Contributor

/etc/nsmb.conf should apply to all users.

To set by command line just script using echo eg.

echo "[default]" >> /etc/nsmb.conf
echo "smb_neg=smb1_only" /etc/nsmb.conf