Linux NFS – set default user for new files on nfs share

file-permissionslinuxnfs

I use CentOs as nfs server nad 2 Centos machines as clients. I have some problems with permisions/ownership for new files/directories created from clients on nfs share.

My exports file:

/media/nfsshare *(rw,sync,no_root_squash)

And my idmap.conf:

[Mapping]
Nobody-User = nobody
Nobody-Group = nobody

Finally, fstab on clients:

172.18.2.132:/media/nfsshare /shared-disk nfs rw,addr=<ip> 0 0

I set /shared-disk permissions to 777 and all clients can create/delete files on mounted share. But:

  • I don't want 777 permissions. I rather need 660
  • Every file created by clients has owner: '-2 – user #-2' and group
    '-2'. I want to ownership for user who created file – system users
    for each client has the same ids, groups and group ids.

Any tips?

Best Answer

Try changing your exports file to...

/media/nfsshare *(rw,sec=sys,sync,no_root_squash)