Linux – How to manage permissions on a Samba mount

file-permissionslinuxnetwork-sharepermissionssamba

I have a Samba server (nas01) which presents a share called downloads. The permissions on that share are as follows:

root@nas01:/mnt/storage/downloads# ls -al
drwxrwxr-x+ 9 phil samba-users 4096 Aug 16 00:09 .
drwxrwxr-x 3 phil samba-users 4096 Aug 13 22:16 ..
drwxrwx---+ 231 phil samba-users 12288 Aug 15 00:56 Movies
drwxrwx---+ 42 phil samba-users 4096 Aug 15 23:15 TV

The users used to remotely access the Samba share are local users on the Samba server and are all in the group samba-users. Locally, on the Samba server itself, those users can access the files:

root@nas01:/mnt/storage/downloads# sudo -u plex ls TV | wc -l
40

When the share is mounted on another Linux server (plex01), this is how it appears:

root@plex01:/mnt/downloads# ls -al
drwxrwxr-x+ 9 phil 1001 0 Aug 15 23:09 .
drwxr-xr-x 3 root root 4096 Aug 18 20:09 ..
drwxrwx---+ 231 phil 1001 0 Aug 14 23:56 Movies
drwxrwx---+ 42 phil 1001 0 Aug 15 22:15 TV

The local root user can access it:

root@plex01:/mnt/downloads# ls TV | wc -l
40

But the local plex user cannot:

root@plex01:/mnt/downloads# sudo -u plex ls TV
ls: cannot open directory TV: Permission denied

If I create a local group with GID 1001 and add the plex user to it… then it can access the files.

root@plex01:/mnt/downloads# ls -al
drwxrwxr-x+ 9 phil plexrunner 0 Aug 15 23:09 .
drwxr-xr-x 3 root root 4096 Aug 18 20:09 ..
drwxrwx---+ 231 phil plexrunner 0 Aug 14 23:56 Movies
drwxrwx---+ 42 phil plexrunner 0 Aug 15 22:15 TV

root@plex01:/mnt/downloads# groups plex
plex : plex plexrunner

root@plex01:/mnt/downloads# sudo -u plex ls TV | wc -l
40

So, the question is… what is the right way to manage these permissions?

  • Is there, for example, a way to mount the share such that local user permissions are not observed? This is an LXC container specifically for running Plex, so that is probably ok.
  • Can local user permissions be applied to the share without them propagating up to the Samba server and affecting all clients?
  • Am I missing something really obvious here..?

Best Answer

You have to have a way to match IDs (user or group) on server and client. If you're not in an environment using a directory server and such, you can assign ownership through the group. Export the folder with the group set for samba-users. Make sure that the GID for the group is the same on server and client by creating the same group on all the clients and ensuring that the users are members of that group. Set permissions for the folder and all the contents to the group.