Linux – Need help with file permissions on Ubuntu so that NFS clients can read/write

file-permissionslinuxnfspermissionsUbuntu

I have a local Ubuntu development web server and a Mac client which I use to access and edit the files on.

I'm attempting to setup NFS on my Ubuntu server so that I can access the virtual server directories from my OS X client.

I'm having issue with getting the permissions right so that my Mac user can write to a virtual servers' public_html directories.

I've done a bit of reading and it seems you have to match the GUI and UID of the files on the server with that of the logged in user on the Mac to be able to read / write. This kind of make sense and it means that the Unix server thinks I'm the same user as the original owner.

For this to work I think need every virtual server to have the same owner and/or same group otherwise I guess I would have to setup a new user on my Mac client every time I wanted to edit a new site.

What I was think was that I could assign all virtual servers to the same owner and group. Then all I have to do is make sure that user's UID and GID matches that of my Mac user.

To be honest I've never really understood unix permissions so it might be getting this completely wrong. But I really need to be able to read/write to ALL the virtual servers via NFS on my Mac client.

Any help would be greatly appreciated.

Best Answer

You can use the options all_squash, anonuid and anongid in the exports entry. all_squash will redirect all requests on that exported dir to the anonymous user, and the two other options map who are those users on the local machine. Example (from the exports man page):

/home/joe pc001(rw,all_squash,anonuid=150,anongid=100)

All requests on /home/joe will be executed as uid 150 and gid 100. So on each server export the home (or just the public_html) dir using the uid and gid of your local user in the server and the requests coming from your mac client will end on the right permissions.