I'm sharing /data as nfs share with rw, secure and root_squash options from my nfs CentOS server. when I mounted on client it works but I'm getting permission denied if I tried to create file or directory why ? Is that because I have no write permission on shared nfs ??
and how to setup my share so newly created files would have 664 and directories would have 775 permission ??
nfs maps the client user id to the same server user id by default. If that id hasn't write access to /data, your client isn't allowed to write also.
Please submit the output of ls -ldn /data # server side
and id -u; id -g # client side
thanks , I have created the directory /data as root user on nfs server , and the permission rwxr-xr-x thus root or any user on nfs client cannot write to nfs mount unless they have 'w' permission , is that what you mean?
and If promote the permission anyone on the share mount can remove the files or directories , should I add sticky bit to prevent ?
what about new created files and directories how to give 664 and 775 , second part of my inquiry ?
one box to one , I have server and client and that was my first time to use root_squash , I know there's possibility to create specific user and group on server side and client side but just wanted to see the behavior without doing so.
what I need as simple as that , from client side I need any user be able to create files with 664 and directory with 775 , but others can't impact , modify or delete files / dir not belong to ...
centos as well, nfs 4 is the version I'm using which is the default version if I'm not wrong but to be honest and didn't enable from /etc/nfs.conf , should I do so ??
do all of the users have the same primary group (e.g. users) or do they all have their own?
Update/Explanation: If every user has their own primary group (default for Debian & CentOS), then you have to chmod 777 /data, otherwise chgrp <usergroup> /data && chmod 775 /data. This allows all users to write to /data. In any case, each user keeps his uid, as long as no_all_squash is set in /etc/exports, which is the default.
But if you want to use umask 002 (i.e. 664/775) and all the users belong to the same primary group, then they are able to overwrite each other's data (this is independent of the above chmod!).
Setting umask is simple on client side (not via mount options in fstab). On server side, nfs doesn't care about umask, that's only possible with ACLs, see No acl on nfs mount in linux? - Server Fault.
Summarized: Do not use umask 002 unless all users belong to different primary groups.
your directory should belong to something else than root (e.g. bin ) but not necessary but GID must be common to all users with access to this FS, then to avoid others deleting files that aren't theirs you must use directory stick bit, your /share perms should be 1775
About files and directory perms of files created by users, unless you use painkilling ACLs, you can only hope they have been set as default in users environment
as I mentioned I have created the /data nfs shared via uid/gid = root/root. I think now I managed to achieve what I want by chmod 777 /data and add the stick bit chmod +t /data . now user root can create file/dir as needed with ownership nfsnobody/nfsnobody which is normal as root_squash was set , any user can also add file/dir with his/her `'uid/gid' with only one issue if that user was created on server with different uid/gid then the ownership will be messed
same reply , as I mentioned I have created the /data nfs shared via uid/gid = root/root. I think now I managed to achieve what I want by chmod 777 /data and add the stick bit chmod +t /data . now user root can create file/dir as needed with ownership nfsnobody/nfsnobody which is normal as root_squash was set , any user can also add file/dir with his/her `'uid/gid' with only one issue if that user was created on server with different uid/gid then the ownership will be messed
for this you have to give each corresponding user the same id on server side with usermod -u uid -g gid user, but watch out for duplicate ids. Maybe linux - NFS user mapping - Server Fault will also help.