Permission problem Samba / Nextcloud

Hello!

I’m running the latest version of Nextcloud on an Ubuntu 18.04 Server.
I have the following situation: I’m using a second internal drive as “external storage” in Nextcloud, which is mounted at /mnt/intern
I am also accessing this folder via the network using samba with the user “andreas” from my MS Windows computer.

Everytime I create a folder via the network (samba), I only have read-permissions when I later access the folder via Nextcloud Web-Interface (“You don’t have permission to upload or create files here”). When I create the folder via the Nextcloud Web-Interface, everything is fine and I can manipulate the files using Nextcloud and my Windows computer.

Example: Folder 1 has been created using the Nextcloud Interface, Folder 2 via samba.
drwxr-xr-x 2 www-data www-data 4096 Jan 26 08:11 ‘Folder 1’ --> this one works fine
drwxr-xr-x 2 andreas andreas 4096 Jan 26 08:12 ‘Folder 2’ --> for this folder, I cannot change anything in the Web-Interface

Is there a way to let both users (www-data and andreas) access the folder via the Web-Interface? Or a different approach?

Thanks!

It seems like I was able to fix the problem, here is the solution:

Add this to your /etc/samba/smb.conf:

force group = www-data
create mask = 0770
directory mask = 0771
force create mode = 0660
force directory mode = 0770

1 Like

I also had to add this:
force user = www-data

Its better to use webdav to access the ncdata, this way you dont need to rescan files.

I’m in the same situation, I have a NAS at home that share folder via SMB, I want to be able to access these folder through Nextcloud so I configured these folders as external storage using smbclient.

It’s the only solution I’ve found to be able to access my files directly in the explorer at home AND through Nextcloud when I’m not at home.

But maybe it’s more efficient to have these folder directly in the Nextcloud server in “local” and then share them via webdav and just configure all client to access the folder via webdav and not use samba anymore.

Except that from what I saw, SMB is better on a local network and webdav is better (and more secure) from the internet. Soo here we are :no_mouth:

this was listed in the smb configuration guide on (https://ownyourbits.com/2017/04/16/share-your-files-in-your-lan-with-samba/) for ncp and if you activate smb from the webui it creates this by default

how ever iwe ran into a problem where im mapping my secondary drive to use as a nas only offline
but cant seem to configure it properly to give permissions to windows 7

The downside of smb is that nextcloud is not aware of what is happening. Thats why you have to run a chron to rescan the files for changes frequently. Webdav however nextcloud is aware of and the changes are in nc immediately.

Yes, but WebDAV isn’t suitable for internal network sharing especially for large file.

I cannot confirm this downside. When I copy a folder with some subfolders and hundreds of pictures via SMB to the server, I do immediately see the folders and the pictures in NextCloud (AJAX is selected in the admin-menu) - everything works perfectly!