DroidOS
DroidOS

Reputation: 8910

nfsnobody User Privileges

I have setup an NFS file share between two CentOS 6, 64 machines. On the server the folder being shared was originally owned by the root user. On the client it turned up as being owned by nfsnobody. When I tried to write to the folder from the client I got a permissions error. So I changed the folder ownership on the server to nfsnobody and chmod'd it to 777. However, still no joy - I continue to get a permissions error. Clearly, there is more to this. I would be much obliged to any Linux gurus out there (I personally wouldn't merit being called anything more than a newbie) who might be able to help fix this issue.

Edit - I should have mentioned that trying to write to the shared folder from the client actually manages to create a file entry. However, the file size is 0 and the permissions error is reported.

Upvotes: 4

Views: 42256

Answers (1)

DroidOS
DroidOS

Reputation: 8910

The issue here is to do with the entry in /etc/exports. It should read

folder ip(rw,**all_squash**,sync,no_subtree_check)

I had missed the all_squash bit. That apart, make sure that the folder on the server is owned by nfsnobody. On my setup both my client and server nfsnobodies ended up with a user id if 65534. However, it is well worth checking this (/etc/groups) or else... .

Here are a couple of useful references

How to setup an NFS SErver NFS on CentOS

For the benefit of anyone looking to setup an NFS server I give below what worked for me on my CentOS 6 64bit machines.

SERVER
yum install nfs-utils nfs-utils-lib  - install NFS
rpm -q nfs-utils - check the install

/etc/init.d/rpcbind start
chkconfig --levels 235 nfs on
/etc/init.d/nfs start
chkconfig --level 35 rpcbind on

With this done you should create the folder you want to share

mkdir folder
chown 65534:65534 folder
chmod 755 folder

Now define the folder to be shared/exported. Use your favorite text editor (vi or whatever) to open/create /etc/exports

 folder clientIP (rw,all_squash,sync,no_subtree_check)

 Client
 Install, check, bind and start as above
 mount -t nfs serverIP:folder clientFolderLocation

If all goes well you should now be able to write a little script on your client

<?php
$file = $_SERVER['DOCUMENT_ROOT']."/../nfsfolder/test.txt";
file_put_contents($file,'Hello world of NFS!');
?>

browse to it and find that test.txt now exists on the server with the content "Hello world of NFS". In the example I have placed my mounted drive one level before document_root.

Upvotes: 5

Related Questions