# Samba Authentication error



## kr651129 (Sep 12, 2012)

I'm trying to mount my samba share on FreeBSD 9.1 via the following


```
# mount_smbfs //kclark@server/samba "./My Music"
Password:
mount_smbfs: unable to open connection: syserr = Authentication error
```

I'd really like this to automount on boot but I need to get this working first.

Here's my smb.conf


```
[global]
workgroup    = SMB
netbios name = SERVER
security     = user

[samba]
writeable     = yes
path          = /usr/home/samba
public        = yes
guest ok      = yes
guest only    = yes
guest account = nobody
browsable     = yes
```


----------



## gkontos (Sep 12, 2012)

Have you added the user in samba?

[CMD=""]# smbpasswd -a <user>[/CMD]


----------



## kpa (Sep 12, 2012)

You have guest only = yes in your configuration, that will allow only guest logins without a password. Turn that off to use the real user accounts for login.


----------



## mamalos (Sep 12, 2012)

Moreover, in order to debug your connections more thoroughly -and not deal with probable configuration issues of mount_smbfs-, use:

`$ smbclient //server/samba -Ukclark`

followed by your password to see that everything is fine. If in doubt, check what shares are present with:

`$ smbclient -L server -U%`

If the above work, while mount_smbfs fails, post us the contents of your ~/.nsmbrc file.


----------



## kr651129 (Sep 12, 2012)

`# smbpasswd -a <user>`

Solved this for me, but my next question gets a little more complex.  I want to automount the share via /etc/fstab but I'm being prompted for a password, I'd like to not have to enter a password, but here's the tricky part, if I'm at home I want an entry for my server behind the router, when I'm connected elsewhere I want an entry for my static IP, when FreeBSD loads the /etc/fstab will it pass over the "invalid" entry or will it error out on me and force me to fix this in single user mode?


----------



## SirDice (Sep 12, 2012)

kr651129 said:
			
		

> when FreeBSD loads the /etc/fstab will it pass over the "invalid" entry or will it error out on me and force me to fix this in single user mode?



It will error and drop you to single usermode.


----------



## kr651129 (Sep 12, 2012)

Is there a way around this or is my best bet writing a bash script that autoruns on login?


----------



## kr651129 (Sep 12, 2012)

Well I wrote this script and it seems to work fine, but I need to get around the password request


```
#!/usr/local/bin/bash

echo "Checking to see what router we're connected to..."
echo ""


SSID=$(/sbin/ifconfig | grep ROUTERNAME)

echo "Connected to "
echo $SSID


if [[ "$SSID" == *ROUTERNAME* ]]
then
        echo "Connecting to krisbox from inside the network"
        mount_smbfs //kclark@server/samba "/usr/home/kclark/My Music"
else
        echo "Connecting to krisbox from outside the network"
        mount_smbfs //kclark@xxx.xxx.xx.xxx/samba "/usr/home/kclark/My Music"
fi
```


----------



## gkontos (Sep 12, 2012)

kr651129 said:
			
		

> Well I wrote this script and it seems to work fine, but I need to get around the password request



See here for bypassing the password. You can also adjust your script.


----------



## kr651129 (Sep 13, 2012)

gkontos said:
			
		

> See here for bypassing the password. You can also adjust your script.



Thanks for the link, I tried that and it still is prompting me for a password, this might be a stupid question, but that file goes on the client box right?


----------



## gkontos (Sep 13, 2012)

kr651129 said:
			
		

> Thanks for the link, I tried that and it still is prompting me for a password, this might be a stupid question, but that file goes on the client box right?



Correct, have you tried to declare the user in capital in .nsmbrc?  You can also add the credentials in the fstab but this is not recommended.


----------



## Sparkee (Oct 29, 2013)

Did you solve this issue?


----------



## kr651129 (Oct 31, 2013)

I did, I can't remember how off hand but I'm testing 10.0-BETA2 right now and I'll be setting this up again, when I do I'll let you know what the solution was.


----------



## Sean G (Apr 5, 2016)

I know this is an older thread but I just went through the same problem with 10.3

After a lot of trial and error, I found that server name and username must be in capitals.


```
[SERVERNAME]
addr=192.168.1.nn

[SERVERNAME:USERNAME]
# use persistent password cache for username
password=PasSwoRd
```

Hope this saves someone some time...


----------



## xelfer (Sep 4, 2016)

Sean G said:


> I know this is an older thread but I just went through the same problem with 10.3
> 
> After a lot of trial and error, I found that server name and username must be in capitals.



This did fix my issue, thank you.


----------

