FreeBSD 11.0 and mounting SMB shared folder at boot without password

1,270 views
Skip to first unread message

David Christensen

unread,
Jan 19, 2017, 11:35:58 PM1/19/17
to freebsd-...@freebsd.org
freebsd-questions:

I have a computer:

toor@freebsd:/root # freebsd-version
11.0-RELEASE-p7

toor@freebsd:/root # uname -a
FreeBSD freebsd 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu
Sep 29 03:40:55 UTC 2016
ro...@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386


I am attempting to mount a Microsoft Windows shared folder
(//dc8ct591/data) into my home directory
(freebsd:/usr/home/dpchrist/.data) at boot, without having to enter my
password.


Using Xfce and Thunar, I can browse the network, see the shared folder,
enter my credentials, and access files within the share.


After RTFM and STFW, this is my current attempt:

toor@freebsd:/root # ll /etc/fstab
-rw-r--r-- 1 root wheel uarch 230 Jan 19 19:41 /etc/fstab

toor@freebsd:/root # grep dc8ct591 /etc/fstab
//dpchrist@dc8ct591/data /usr/home/dpchrist/.data smbfs rw,-N 0 0

toor@freebsd:/root # ll /etc/nsmb.conf
-rw------- 1 root wheel uarch 85 Jan 19 19:42 /etc/nsmb.conf

toor@freebsd:/root # cat /etc/nsmb.conf
[default]
workgroup=WORKGROUP
[dc8ct591:dpchrist]
password=<redacted>


If I run 'mount' with the -d option, I can see the system call to
'mount_smbfs':

toor@freebsd:/root # mount -d /usr/home/dpchrist/.data
exec: mount_smbfs -o rw -N //dpchrist@dc8ct591/data /usr/home/dpchrist/.data


If I then run 'mount_smbfs' without the -N option and enter the password
for dpchrist@dc8ct591, it works:

toor@freebsd:/root # mount_smbfs -o rw //dpchrist@dc8ct591/data
/usr/home/dpchrist/.data
Password:

toor@freebsd:/root # mount | grep -i dc8ct591
//DPCHRIST@DC8CT591/DATA on /usr/home/dpchrist/.data (smbfs)


But if run 'mount', or 'mount_smbfs' manually with the -N option, it fails:

toor@freebsd:/root # umount /usr/home/dpchrist/.data

toor@freebsd:/root # mount | grep -i dc8ct591

toor@freebsd:/root # mount /usr/home/dpchrist/.data
mount_smbfs: unable to open connection: syserr = Authentication error

toor@freebsd:/root # mount_smbfs -o rw -N //dpchrist@dc8ct591/data
/usr/home/dpchrist/.data
mount_smbfs: unable to open connection: syserr = Authentication error


I get the same result for shared folders on Samba 2:3.6.6-6+deb7u11 on
Debian 7 (Wheezy) and on Windows XP SP2.


I don't know how to get more information about the "Authentication
error" encountered by mount_smbfs (no --verbose or --debug option, and
doesn't seem to write into any file in /var/log).


Any suggestions?


David
_______________________________________________
freebsd-...@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

David Christensen

unread,
Jan 20, 2017, 4:48:02 PM1/20/17
to freebsd-...@freebsd.org
On 01/19/17 20:35, David Christensen wrote:
> I am attempting to mount a Microsoft Windows shared folder
> ... into my home directory ... at boot, without having to enter my
> password.

I figured it out:

1. Configuration file for mount_smbfs -N option must be /etc/nsmb.conf:

a. /usr/home/dpchrist/.nsmbrc does not work.

b. /usr/local/etc/nsmb.conf does not work.

c. /root/.nsmbrc works when mount_smbfs is invoked from the
command line, but fails at boot.

2. The (SMB) user name and host name in /etc/nsmb.conf must be upper
case (my workgroup name was already upper case).

3. For better security, I adjusted permissions of /etc/nsmb.conf and
encrypted my (SMB) password using smbutil(1).


A console session follows.


David



toor@freebsd:/root # vim /etc/fstab

//dpchrist@cd2533/data /usr/home/dpchrist/.data smbfs rw,-N 0 0

toor@freebsd:/root # touch /etc/nsmb.conf

toor@freebsd:/root # chmod 0600 /etc/nsmb.conf

toor@freebsd:/root # smbutil crypt >> /etc/nsmb.conf
Password:

toor@freebsd:/root # vim /etc/nsmb.conf

[default]
workgroup=WORKGROUP
[CD2533:DPCHRIST]
password=$$1<redacted>

toor@freebsd:/root # ls -l /etc/nsmb.conf
-rw------- 1 root wheel 83 Jan 20 13:33 /etc/nsmb.conf

toor@freebsd:/root # mount | grep smbfs

toor@freebsd:/root # mount /usr/home/dpchrist/.data

toor@freebsd:/root # mount | grep smbfs
//DPCHRIST@CD2533/DATA on /usr/home/dpchrist/.data (smbfs)

toor@freebsd:/root # shutdown -r now

toor@freebsd:/root # mount | grep smbfs
//DPCHRIST@CD2533/DATA on /usr/home/dpchrist/.data (smbfs)

J.B.

unread,
Jan 20, 2017, 10:42:43 PM1/20/17
to freebsd-...@freebsd.org
On 01/20/2017 04:00 AM, freebsd-ques...@freebsd.org wrote:
> Send freebsd-questions mailing list submissions to
> freebsd-...@freebsd.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> or, via email, send a message with subject or body 'help' to
> freebsd-ques...@freebsd.org
>
> You can reach the person managing the list at
> freebsd-que...@freebsd.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of freebsd-questions digest..."
>
>
> Today's Topics:
>
> 1. FreeBSD 11.0 and mounting SMB shared folder at boot without
> password (David Christensen)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 19 Jan 2017 20:35:42 -0800
> From: David Christensen <dpch...@holgerdanske.com>
> To: freebsd-...@freebsd.org
> Subject: FreeBSD 11.0 and mounting SMB shared folder at boot without
> password
> Message-ID: <3a018208-2ad4-1b1d...@holgerdanske.com>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> freebsd-questions:
>
> I have a computer:
>
> toor@freebsd:/root # freebsd-version
> 11.0-RELEASE-p7
>
> toor@freebsd:/root # uname -a
> FreeBSD freebsd 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu
> Sep 29 03:40:55 UTC 2016
> ro...@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC i386
>
>
> I am attempting to mount a Microsoft Windows shared folder
> (//dc8ct591/data) into my home directory
> (freebsd:/usr/home/dpchrist/.data) at boot, without having to enter my
> password.
>
>
> toor@freebsd:/root # umount /usr/home/dpchrist/.data
>
> toor@freebsd:/root # mount | grep -i dc8ct591
>
> toor@freebsd:/root # mount /usr/home/dpchrist/.data
> mount_smbfs: unable to open connection: syserr = Authentication error
>
> toor@freebsd:/root # mount_smbfs -o rw -N //dpchrist@dc8ct591/data
> /usr/home/dpchrist/.data
> mount_smbfs: unable to open connection: syserr = Authentication error
>
>
> I get the same result for shared folders on Samba 2:3.6.6-6+deb7u11 on
> Debian 7 (Wheezy) and on Windows XP SP2.
>
>
> I don't know how to get more information about the "Authentication
> error" encountered by mount_smbfs (no --verbose or --debug option, and
> doesn't seem to write into any file in /var/log).
>
>
> Any suggestions?
>
>
> David
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> freebsd-...@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"
>
> ------------------------------
>
> End of freebsd-questions Digest, Vol 659, Issue 7
> *************************************************

-N Do not ask for a password. At run time, mount_smbfs reads the
~/.nsmbrc file for additional configuration parameters and a
password. If no password is found, mount_smbfs prompts
for it.

Looks like mount_smbfs is expecting the file to be named '.nsmbrc', not
simply 'nsmbrc.' So it's not finding the file where the password is stored.

J.B.

unread,
Jan 20, 2017, 10:48:51 PM1/20/17
to freebsd-...@freebsd.org
On 01/20/2017 04:00 AM, freebsd-ques...@freebsd.org wrote:
> FreeBSD 11.0 and mounting SMB shared folder at boot without
> password (David Christensen)

I didn't read far enough. The method (and file) you're using appears to
be a valid option:

# smbfs lookups configuration files in next order:
# 1. ~/.nsmbrc
# 2. /etc/nsmb.conf - if this file found it will
# override values with same keys from user files.


Have you tried using ~/.nsmbrc instead?
Reply all
Reply to author
Forward
0 new messages