Help with NFS user rights

I have an NFS share that I share with different users. I repeatedly encounter the problem that when one user uploads a file, the other users cannot access it.

Recently, I (userA) uploaded photos to a subfolder using Digikam and Dolphin from my computer.
When checking the file permissions, I noticed that the files have been assigned very different permissions and group:
-rw------- 1 userA users 4637149 12. Sep 15:37 picture1.jpg
-rw------- 1 userA users 4913440 12. Sep 15:37 picture2.jpg
-rw-r--r-- 1 userA groupA 7914920 11. Sep 15:26 picture3.JPG
-rw-r--r-- 1 userA users 1267294 11. Sep 13:34 picture4.JPG
-rw-r--r-- 1 userA users 1224071 11. Sep 13:34 picture5.JPG
I think this is caused by the different programs (Dolphin, Digikam) that I have used.

The NFS server provides the share with the following configuration:

On my PC, I mount the share as follows:

[Unit] 
Description=Mount /media/Fotos via NFS 

[Mount] 
What=nas:/Fotos 
Where=/media/Fotos 
Type=nfs 
Options=noauto,users,nfsvers=4,rsize=32768,wsize=32768 

[Install] 
WantedBy=multi-user.target 

When userB logs in on the same PC, he doesn’t have the rights to view the images. Both users are in the users group.

Is there a way to ensure that whenever one of the two users copy or creates a file in the share, it is assigned to a specific group and user? Can this be set up via NFS?

Yes, by setting the sgid permission on the directory. :point_down:

chmod 2775 /path/to/directory

The command above will also give write permission to the group that owns the directory. You do however have to make sure first that the directory is owned by the correct group.

More information can be found in the tutorial below… :point_down:

You would normally set it up locally on the server — you can do this via ssh, of course. nfs should honor the local permissions.

3 Likes