Search code examples
linuxpermissionssharemount

Mount linux share cifs as defined user and not "root"


Because I'm using multiple devices to access my files I've moved them to my NAS (192.168.1.31) and am using mounts to access these. Since I've changed my NAS's OS from a windows-based to a linux-based (debian) I had to redo the mounts on my devices (Linux Mint 20.0).

My current fstab is defined as:

//192.168.1.31/Books /home/devicedummy/Books cifs defaults,username=nasdummy,password=nasdummy 0 0

My part from the NAS smb.conf:

workgroup=myplace #same across devices
min protocol = smb2
follow symlinks = yes #for windows aggregate folder
map to guest = bad user #for windows aggregate folder
unix extensions = no #for windows aggregate folder
usershare allow guests = yes
usershare owner only = false

[homes]
comment = Home Directories
browseable = yes
valid users = %S
writeable = yes
create mask = 0775
directory mask = 0775

I expected to have the share mounted with 775 permissions for devicedummy as devicedummy is logged on as nasdummy with these permissions. The result however is that the share is mounted with 755 permissions for "root" resulting in that I can only read the files. When browsing to the same share with Nemo Network>NAS>Books the system can't determine the owner/permissions but all files are writeable.

Which adjustment(s) should I make to achieve the exected situation?

Thanks,


Solution

  • Found the solution and will keep the question here when other people run into the same problem. This one kept me going for a few days unable to find the answer.

    Looking at my fstab I only specified the "outbound user" (don't know if that is the correct term but the credentials which my computer uses to access the NAS) and didn't specify the "inbound user" (as who should the shares be mounted by). Since I didn't specify this the computer went for its default (root). I thought that it used the "inbound user" that was logged on but I was mistaken. With the settings below it did work.

    //192.168.1.31/Books /home/devicedummy/Books cifs defaults,username=nasdummy,password=nasdummy,uid=1000,gid=1000 0 0
    

    With the uid and gid obtained from $ id (devicedummy)