Server: NC 12.0.3: Unable to mount SMB shares

Created on 21 Sep 2017  ·  75Comments  ·  Source: nextcloud/server

Expected behavior

Nextcloud should be able to mount external SMB shares.

Current behavior

Nextcloud seems not able to always mount an external SMB share, provided via a Samba server, in a reliable way. The usual square in front of the share is displayed, which indicates an authentication problem, although all required information have been entered correctly. On top of the external mount screen the message "Verbindung zum Server verloren" (lost connection to server) is shown for a short moment.

I've double-checked that libsmbclient is installed and activated on the web server as recommended in other postings. Additionally I've tested access to the share using the smbclient command line tool:

# smbclient //192.168.1.11/Tmp -U "juergen"

Additionally I've written a small PHP script to check if the given SMB share can be accessed properly using the smbclient functions:

<?php
// Create new state:
$state = smbclient_state_new();

// Initialize the state with workgroup, username and password:
smbclient_state_init($state, '', 'juergen', 'XXXXX');

// Open a directory:
$dir = smbclient_opendir($state, 'smb://192.168.1.11/Tmp');

// Loop over the directory contents, print each node:
while (($entry = smbclient_readdir($state, $dir)) !== false) {
    echo "{$entry['name']} : {$entry['type']}<br>\n";
}

// Close the directory handle:
smbclient_closedir($state, $dir);

// Free the state:
smbclient_state_free($state);
?>

Everything works fine, except that it doesn't work from within Nextcloud :-( No error messages are shown in the Nextcloud log or elsewhere which gives a hint about the possible root cause of the problem.

Due to the fact that problems with external mount points appears very often I would recommend to add a kind of diagnosis function to each external mount function which allows double-check the base requirements and shows detailed information, including all steps of a mount attempt.

BTW: I've managed to created several identical mount configurations within seconds only by editing the SMB mount options of my test share. It seems that there is another issue with the external mount configuration dialog itself.

Steps to reproduce

  1. In my closed environment it is easy, but most likely in your test it isn't.

Environment

Server Configuration

OS: Linux 3.16.47
Web server: Apache2 2.4.26
PHP version: 5.6.29
Database: MariaDB 10.0.32
Nextcloud version: 12.0.3

Client Configuration

Browser: Mozilla Firefox 55.0.3
Operating system: Windows 7

0. Needs triage bug external storage

All 75 comments

From my upgrade from 11.x to 12.0.3 i had this problem too. problem was solved by entering the domain in the external mount options.

@r3pek Thanks for the hint but I tried it with and without a domain name, I used an ip address, the servers short and FQDN name, I've written the server name in upper and lower case, etc., etc. without any success. That's weird, isn't it?!

@j-ed sorry, maybe i wasn't clear enough ;)

image

I ment that "Domain" field. Not a "domain" in the "Host" field.

@r3pek Sorry, if it wasn't clear, I naturally tried it with the (Windows/Samba) domain name in the Domain field but it had not influence on the result.

smb server (CENTOS 7)
nextcloud 12.03

I had the same problem. I tested it all the same way j-ed did with 'smbclient' via the command line and it all passed. I fixed my problem by putting in my smb servers domain name (which was 'home') and it got the green light on my 'external storages' config where they were red after upgrading from 12.02 to 12.03.

thanks

Today I've installed the smbwebclient.php script (https://sourceforge.net/projects/smbwebclient/files/) on my server and had also no problems to access files using SMB. What makes the Nextcloud app so specific that I cannot get it running?

Had problems too after setting server min protocol to SMB2 on my Samba server. After disabling this option, Nextcloud was able to mount shares again.

@drhirn I've tested it with the default of server min protocol = LANMAN1 and also with server min protocol = SMB2 as recommended in other discussions. Due to the fact that access is possible with the smbclient command line program and also with the smbclient php-functions outside of the Nextcloud environment I assume that there is still bug in the Nextcloud implementation.

I have same bug. Cannot mount samba shares anymore

Hi folks.
I got the same issue connecting to my freenas smb share after updating to 12.0.3.
Using "smbclient //192.168.11.121/myShare$ -U "myUser" " works fine.

Neither using IP or name doesn't help nor providing domain/workgroup.

My setup:
OS: CentOS Linux release 7.4.1708 (Core)
WebServer: httpd-2.4.6-67.el7.centos.6.x86_64
Nextcloud: 12.0.3
PHP: php70w-7.0.24-1.w7.x86_64

NAS:
Freenas 9.10.2 U6

Sniffing traffic between NC and the NAS reveals the following message:

20:23:05.410723 IP (tos 0x0, ttl 64, id 4498, offset 0, flags [DF], proto TCP (6), length 91)
192.168.99.104.445 > 192.168.99.126.55666: Flags [P.], cksum 0x0d8b (correct), seq 766:805, ack 1274, win 1040, options [nop,nop,TS val 332947403 ecr 1373316036], length 39
SMB PACKET: SMBtconX (REPLY)
SMB Command = 0x75
Error class = 0x22
Error code = 49152 (0xc000)
Flags1 = 0x88
Flags2 = 0x3
Tree ID = 65535 (0xffff)
Proc ID = 17839 (0x45af)
UID = 42148 (0xa4a4)
MID = 6 (0x6)
Word Count = 0 (0x0)
NTError = STATUS_ACCESS_DENIED
smb_bcc=0

Havin' a look into the smbd log at the nas says:
[2017/10/26 20:44:02.869547, 2, pid=35643, effective(0, 0), real(0, 0)] ../source3/smbd/service.c:319(create_connection_session_info)
guest user (from session setup) not permitted to access this share (myShare$)

Any help appreciated.

Thanks in advance.
Regards,
Alex

Also its problem that its not possible to downgrade nextcloud to previos version (12.0.2 or so)

same bug here.

same here

I know it's not a true resolution to the problem, but if all the components/packages are installed on your machine.. you can mount the network shares via /etc/fstab - this will auto-mount them at boot.

In Nextcloud, it will see these the network mounts as local storage and it easy and quick to setup this way.

I used this walk thru: https://wiki.ubuntu.com/MountWindowsSharesPermanently

@brando-online
thx for your idea.
solve temporary my problem

Any idea when this issue will be fixed? Currently on of NC features totaly br0ken (i tryed 12.0.x , x>2 and 13.0.0 beta's)

Is this normal?
Since Setember to correct a bug?
I'm new in nextcloud, i always use owncloud since the beginning and i'm starting to regret the change.

I have the same problem on my setup too, since 16 months (since I use nextcloud)

works:
nc

doesn't work:
nc2

So I can only access sub-directorys of samba shares, not the share directly. Pretty annoying because I'd like to access the /C$ share of my Windows Server sometimes.

I've Nextcloud 13.0beta4 is running on Ubuntu Server 16.04 LTS on HyperV on Windows Server 2016.14393.1944

calling out @icewind1991

There seems to be multiple separate issues being reported here.

To help debug smb issues you can clone https://github.com/icewind1991/SMB, run composer install, edit example.php with the relevant smb details and run example.php

I have this same issue since at least 12.0.3. Feedback below is based on 12.0.4.

I found that what is failing on my particular set up is the auth file being provided via the /proc/self/fd/3

When I change apps/files_external/3rdparty/icewind/smb/src/RawConnection.php function writeAuthentication to point to a physical file which I create with the content provided by getAuthStream() then everything "just works".

@icewind1991 I followed your test instructions regarding the example.php in https://github.com/icewind1991/SMB and that again "just works". Apologies for tagging you in both issues I was not confident which was the best place for this 12.0.4 feedback and wanted to avoid creating another for that version.

What version of smbclient are you using?

I know that newer version of smbclient don't like my /proc trick and the library has been updated to handle it but that hasn't been backported to 12.0.x yet.

You can try and see if https://github.com/nextcloud/server/pull/7774 fixes the problem

Thank you @icewind1991 after some quick tests it appears as if #7774 does indeed fix the issue for us.

Hi,

I'm also having the same problem : i can't use SMB shares in active directory domain...

How do you apply the fixes in #7774 please ?

Thanx !

@jaydee99 It's included in the latest maintenance releases. So just upgrade to the latest version of Nextcloud and try if it works. Please report back here if it does.

Thanks!

@enoch85 still same problem. I'm on nextcloud 13.0.0 RC 2 with External storage support 1.4.1

@icewind1991 What changed in 12.0.0 that broke SMB, since it's confirmed working in 11.0.3?

If you arent on a domain , can you try putting in . (yes dot '.') as the domain. That fixed the issue for me.

What changed in 12.0.0 that broke SMB, since it's confirmed working in 11.0.3?

I think it's likely that it's not the Nextcloud update, but an smbclient update that broke it

@icewind1991

I think it's likely that it's not the Nextcloud update, but an smbclient update that broke it

If that's the case, wouldn't it be possible to patch that in your libs? I have numerous clients/customers who are running the latest VM (Ubuntu 16.04.3) and it doesn't work.

Feel free to download the VM for testing purpose.

Hi,

Did anyone found a fix for this ?

Thanx !

EDIT : SMB shares are working with Invite access enabled... Otherwise it doesn't work

Last update is fixed.

Em 02/02/2018 15:57, "jaydee99" notifications@github.com escreveu:

Hi,

Did anyone found a fix for this ?

Thanx !


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/server/issues/6597#issuecomment-362616104,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AgZEeMNMmCcB4U5JMbJLFduYETn2qQk0ks5tQyh4gaJpZM4PfBZw
.

If it's 12.0.5 it's not fixed for me

Hello.

For me, updating to 12.0.5 fixed the issue.
Thanks a lot.

I have the same problem , im running NC 13.0

I update to NC 13.0 and is working.
Are using a domain?
Is your samba share working ouside the NC?

Com os meus melhores cumprimentos,

Nuno Catarino

2018-02-09 2:57 GMT+00:00 unrealwzg notifications@github.com:

I have the same problem , im running NC 13.0


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/nextcloud/server/issues/6597#issuecomment-364320731,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AgZEeOOL0QyHRBVYSwsYe75gRvxjj2mEks5tS7QpgaJpZM4PfBZw
.

I am also having issues with mounting smb shares on a fresh installed (ubuntu) lemp stack with Nextcloud 13.0.0.
What me really bugs, is that I don't get any feedback but a red square. Can't you print out some logs?!

I'm also having the same issues using NC 13.0.0.0

Wanted to let you all know that I'd also had some troubles with version 13.0.0 - but after looking at my settings, seems the logs generated the errors when the SMB shares do not mount correctly due to permission/path problems. After I got my permissions & shared path correctly mapped, the errors stopped coming up. Double check your share permission & paths -or- blow permission wide open for troubleshooting and then restrict it back down after remedying the issue.

I can connect to the share just fine, it also shows a green dot. Nothing shows up and when i click on it under external storages it just loads back to the files page and shows me my working seagate nas server. NAS server works no problem, windows share is like a no go.

smb4
smb
smb2
smb3

@bryantjopplin sounds like the same problem which I have

@FaySmash i have a temp work around working great. but would like to do it the normal way.

I can mount via fstab and then add it locally to nextcloud and it works.

But would not like to do it this way as its slower. And when i setup ldap this wont work

Not worrried about username or pw this is testing only lol.

//192.168.1.2/e /home/hss/storage cifs username=aosp,password=aosp,iocharset=utf8,sec=ntlm,nosetuids,noperm

smb5
smb6

@FaySmash Whats funny is i just setup smb server on my android phone (Pixel 2 XL) and connected it via smb and it works fine as well. Definitely something between nextcloud and windows shares/smb directly.

smb8
smb7

@bryantjopplin I don't want to mount the share outside of nextcloud, I don't need the function to access the root of the share that much. so in conclusion, it seems the external storage addon can't handle the attempt to open the root of a windows share(?)

@FaySmash Heck I can't even mount a sub directory let alone the root directory of a Windows share. Even though I get the green light. So you have stopped trying to connect to it?

Got smbclient for php7.2 working using this method. But still no connection to windows share

sudo apt-get install libsmbclient-dev

sudo pecl install smbclient

sudo bash -c "echo extension=/usr/lib/php/20170718/smbclient.so > /etc/php/7.2/cli/conf.d/smbclient.ini"

sudo bash -c "echo extension=/usr/lib/php/20170718/smbclient.so > /etc/php/7.2/apache2/conf.d/smbclient.ini"

sudo service apache2 restart

Connected Via AD and was able to connect to the windows server fileshare no issue. Wonder what the deal with Windows 10 is?

Can confirm this error for share on Windows 2016 Server within AD. Current Nextcloud 13 version is running on current Ubuntu 17.10. No chance to connect to share in NC thought smbclient on console works fine. Tried out everything in NC GUI with different domain/user combinations. Connecting to older 2008 hosts works fine. I assume something with SMB Signing with SMB3.11.

I can confirm this error. No chance to connect to share in NextCloud. smbclient via console works fine. To windows server 2008 works fine.
Ubuntu 16.04.5 LTS
Nextcloud 13.0.5
Server 2016 with AD

New recognition on Server 2008:
Earlier created share run on NC. One new created not.

I found a solution.
When the php has only smbclient command - no libsmbclient or php smbclient module -, the php uses smbclient command by using 'shell_exec' function.

apps/files_external/3rdparty/icewind/smb/src/System.php:32
$this->smbclient = trim(which smbclient);

shell_exec function refer to enviroment variables, so we have to set "PATH".
but my case, enviromental variables was cleared because php-fpm config file has "clear_env = yes". I changed "clear_env" of php-fpm config file from "YES" to "NO". the nextcloud became to be able to access smb directory.

I can connect to the share just fine, it also shows a green dot. Nothing shows up and when i click on it under external storages it just loads back to the files page and shows me my working seagate nas server. NAS server works no problem, windows share is like a no go.

smb4
smb
smb2
smb3

Same problem.
CentOS 7+ php7.0 + nginx + MySQL + smbclient

I can mount "//192.168.1.2/E/Inner" ,but not “//192.168.1.2/E” , "//192.168.1.2/E/杂" not work too.

I find a better solution:

  1. Install "cifs-utils" with yum (for CentOS 7 for me).

2.Mount SMB Share with some parameter.
For example,I modified “/etc/fstab”,add a line

//192.168.1.100/E /var/www/nextcloud/data/smb/E cifs dir_mode=0755,file_mode=0755,uid=997,gid=995,username=nextcloud,password=password,vers=3.0,rw
SMB Share is : //192.168.1.100/E
Target Folder is : /var/www/nextcloud/data/smb (I put the mount point in nextcloud data folder)
(The folder should owned by group of user runing nextcloud)
Uid and gid is from the user runing nextcloud.
Username and password is for the SMB Share.
So I mount a SMB Share and nextcloud can access it.

3.Add external storage in nextcloud,select local,path is on above(/var/www/nextcloud/data/smb/E).

At end nextcloud can access external SMB Share as a local folder.

I used to mount SMB Share directly in the nextcloud user data folders,but update file info periodically with occ file:scan is not a good idea.

I found a solution.
When the php has only smbclient command - no libsmbclient or php smbclient module -, the php uses smbclient command by using 'shell_exec' function.

apps/files_external/3rdparty/icewind/smb/src/System.php:32
$this->smbclient = trim(which smbclient);

shell_exec function refer to environment variables, so we have to set "PATH".
but my case, environmental variables was cleared because php-fpm config file has "clear_env = yes". I changed "clear_env" of php-fpm config file from "YES" to "NO". the nextcloud became to be able to access smb directory.

@ujtwr Thank you for that hint, but I think lowering the security settings for the whole web server shouldn't be the preferred way to go. Best would be if the path to the smbclient binary could be set as a parameter within Nextcloud?!

@icewind1991 I've just upgraded my test environment to Nextcloud 15 and started running some tests.
Unfortunately the reported SMB mount problem hasn't been solved yet. I though it would worse to run some more tests which might help identifying the root cause of the problem.

First I tried to run a test with your smb_test app, which shows that the php-smbclient backend is installed and used. I entered the SMB mount details and pressed the Test button but the only output was Loading share content. I checked the server log file and saw that a segmentation fault has appeared right after I ran the test.

Then I used my initial test script (see initial issue ticket) to check if it is generally possible to access a SMB share using the smbclient library. As expected that worked without any problems.

Now I downloaded your wrapper for smbclient and libsmbclient-php and followed the provided test description. I was really surprised as it showed the SMB share content on the command line and also via the web server with any problems too.

As far as I understood your smb_test app relies on your PHP wrapper functions. Now I wonder why it is possible that the wrapper itself seems to work but not your smb_test app nor Nextcloud. Do you have any ideas what else I could check to narrow down the problem.

I use NC 15 in docker version, but I see that this bug is present in the normal server too. This needs to be fixed asap, as it's a feature-breaking bug and will not help Nextcloud go on production servers. Any news?

EDIT: and suddenly it works. Maybe you just need to restart the docker app, I don't know.

Installed 15.0.4 yesterday and I could not manage to connect to a SMB share.

Installed 15.0.4 yesterday and I could not manage to connect to a SMB share.

The following fixed my issue
Edit /etc/samba/smb.conf adding the lines below [global]

client min protocol = SMB2

client max protocol = SMB3

and reboot

15.0.4 , all smb shares working perfectly, but the log is filled with many errors:
smbclient_state_errno(): supplied resource is not a valid smbclient state resource at /var/www/nextcloud/apps/files_external/3rdparty/icewind/smb/src/Native/NativeState.php#57

If using smbclient-php, the subfolder field can't be empty at the external storage setup
Putting a \ there makes it work. This problem doesn't occur if the smbclient-php is not installed!

I just checked how many issues have been reported which are related to "SMB". There are currently 31 open tickets, which most likely could all be solved by fixing the Nextcloud SMB integration. I think a lot of things have been analyzed in the meantime but without getting the right attention of the Nextcloud team we won't get any further with it.

You are aware that

you using external storage, if yes which one: local/smb/sftp/...

is part of the issue template? If you take a closer look at the 276 open "SMB" tickets you may notice that your figure is wrong.

@kesselb Sorry, I saw only matched in the title, but you're absolutely right there were also matches in the text. I've now updated the search query and figure in my post. Nevertheless it would be nice to get these issues fixed somehow 😉

Did some tests with https://github.com/dperson/samba. Not sure if there is a general problem. Does it work for you if you test it with dperson/samba?

docker run -it -p 139:139 -p 445:445 -d dperson/samba \
            -u "example1;badpass" \
            -u "example2;badpass" \
            -s "public;/share" \
            -s "users;/srv;no;no;no;example1,example2" \
            -s "example1 private share;/example1;no;no;no;example1" \
            -s "example2 private share;/example2;no;no;no;example2" \
            -p 

Hello - I've been doing a little searching so haven't gotten a chance to test thoroughly, but I'm also here because I'm not able to connect to an SMB share on my network, and it just so happens to be a share spun up from the https://github.com/dperson/samba Docker container mentioned above. I have other SMB shares on my network hosted by macOS and Windows, and all of those are accessible just fine,

@kesselb did you discover any cause for not being able to connect to your containers from the dperson/samba container? I didn't think about this as a troubleshooting vector but I will now.

No. It does work for me just fine with the dperson/samba container.

No. It does work for me just fine with the dperson/samba container.

I can't get it to work though, could you share your smb nextcloud config @kesselb please? :)

I figured it out - Nextcloud's smbclient uses SMB1 by default. You must either enable SMB1 on the Samba container or edit the Samba config in next loud to connect with SMB2.

@pdschandler Can you please describe what you mean with ...or edit the Samba config in nextcloud to connect with SMB2. Where and how do I need to set a parameter?

Add to /etc/samba/smb.conf into your php docker/container

[global]
client min protocol = SMB2
client max protocol = SMB3 

@skjnldsv Yes, that's the configuration part if you want to set it for Samba in general. I'm interested in the mentioned Samba config in Nextcloud part. Have I missed a configuration option in Nextcloud?

AH, no idea. Though I can connect with the settings I added :)

same here; latest nextcloud version; no attempt to connect to smb share, traced with tcpdump; no errors in nextcloud.log or apache error.log; it works using smbclient and mount

So, I had the same issue and tried every trick in the thread. For NC 17.0.1 this change fixed it for me link

So, I had the same issue and tried every trick in the thread. For NC 17.0.1 this change fixed it for me link

This fixed it for me as well. Thank you for finding that!

As the version of the software you've reported this for has reached end of life, I will close this ticket. If this is still happening after an upgrade to the latest version, feel free to reopen

Was this page helpful?
0 / 5 - 0 ratings