# non-root user access to nfs mounted partition

## ajaygautam

Hello,

With the help of some fine folks here, I was able to get NFS server working on my Gentoo box, thanks once again for that.

Now, from the client machine, I mount:

mount -t nfs 192.168.1.11:/home/agautam /mnt/disk

I am not able to assign access to a user on the client machine. eg. I have a user joe to whom I would like to give write acces to the moounted partiton.

On the server, my /etc/exports file contains:

/home/agautam 192.168.1.0/255.255.255.0(rw,all_squash,anonuid=501)

The 501 is of the user joe on the client machine. I wasn't sure if 501 was supposed to be of a user on client or server machine, so I tried both. But none seems to give access to joe. The userid for agautam on server is 1000.

The owner of the mount point on the client machine is 1000, with mod 755.

What am I doing wrong ? Can anyone please help me get access to the local client user ?

Thanks

Ajay Gautam

----------

## fifo

The anonuid should be set to the uid of whoever owns the files and the directories exported on the server. It shouldn't matter which user connects from the client.

----------

## ajaygautam

I have tried setting it to both:

1. Owner of files at server, and

2. The user whom I want to give access on the client.

None work, any other ideas ?

Thanks

Ajay Gautam

----------

## fifo

Is it that the mount command fails, or is it just that the user doesn't get the necessary permissions? What's the exact error message you're getting?

----------

## ajaygautam

The mount command is successful. No errors. But no access either.

On client, as root, I am able to create files in the mounted directory. But as a non root user, I am not able to create files. Says somethings about not having access. I even put the mount stuff in /etc/fstab and mounted as the user, but still I could not write to the mounted directory as the non root user.

Any help to get this working will be highly appreciated.

Thanks

Ajay Gautam

----------

## fifo

Well that seems strange, since "all_squash" is supposed to give every connecting user the same permissions. If it works fine as root, I don't see why it wouldn't work as a user.

Double check the exports file, and run "exportfs -rav". You could also try setting anonuid to 0.

----------

## ajaygautam

Yes, its very strange. Even anonuid=0 does not work. No matter what I do, the directory gets mounted with 1000 as owner, which does not exists on the local machine. And yes, I run export -rav after each modifcation to the exports file.

Here is the exports file once again: (server)

/home/agautam 192.168.1.0/255.255.255.0(rw,all_squash,anonuid=501,anongid=100)

In the exports file, I have tried anonuid=

1000: owner of files on server

501: mounting user on client

0: root

Here is the fstab entry: (client)

192.168.1.11:/home/agautam /home/ajaygautam/NvStation nfs rw,noauto,user,owner 0 3

Any further help will be highly appreciated.

Thanks

Ajay Gautam

----------

## herbie

I think that the numeric id of the owner and group of the files on the server are just carried through to the client. One solution might be to set all the files and directorys on the server, so that they are owned by user 501 and then on the client it would appear that user 501 ie joe owns the files and can therefore write to them. You could also set the group id of the files on the server to that of a group on the client that user joe belongs to and make all the files writable by the group (ie chmod 775 maybe).

Hope that helps,

Herbie.

----------

## ajaygautam

so, basically, what it boils down is to have same user ids on client and servers. Thats not a very pretty solution, nor is it a deisrable one.

SMB based sharing would be easier in that case, I think. What do you say ?

Any other suggestions ?

Thanks

Ajay Gautam

----------

## fifo

It shouldn't be necessary to have the same uids. The files will appear with the same user/group as on the server, but you should still be able to read and write to them just as if you were the user with anonuid on the server.

I'm baffled as to why it does work, I've tried a similar setup and it works fine for me. If you've set anonuid=501, then you shouldn't be able to modify the files, even when you're root--you should have anonuid=1000. What does "ls -ld /home/ajaygautam/NvStation" say after mounting the share? Does it let you write to existing files? If you create a new file on the share (as root presumably) then what owner does it have?

----------

## ajaygautam

 *Quote:*   

> What does "ls -ld /home/ajaygautam/NvStation" say after mounting the share

 

It shows owner as "1000" - the owner of files on the server. As non root user, I am not able to create any files. Access denied.

 *Quote:*   

> Does it let you write to existing files

 

Never tried it, will do so today evening at home.

 *Quote:*   

> If you create a new file on the share (as root presumably) then what owner does it have?

 

I did not check, I just created the file, and then deleted it. Will check today evening.

Thanks

----------

