6

The situation: I simply want to be able to access a Synology NAS from an Ubuntu Server with a non-root user.

On the NAS I have this in the exports-file:

/Directory <client-ip>/255.255.255.0(rw,async,no_wdelay,no_root_squash,insecure_locks,sec=sys,anonuid=1003,anongid=1004)

On the Ubuntu-Server in fstab I got this:

<server-ip>:/Directory  /Mountpoint nfs noauto,user,rw 0 0

Now I want to allow UserA, which is used for some automatic processes to mount the share and write to it.

mount /Mountpoint

Mounting as UserA works fine, but I have no permission to even read what's in the directory. As user root I do. Listing the mountpoint folder shows these permissions:

drwxrwx--- 4 UserA root 4096 Sep 17 13:58 Mountpoint

I tried to set the anon-ids in the exports to the ids of UserA, but that didn't help. Making UserA the owner of the folder didn't help either. Is there a simple thing I am missing?

Also: This needs to be an nfs share as it will transfer large amounts of data.

Edit: I would prefer to avoid giving read and write permissions to "others" for security reasons.

6
  • Did you try setting the permissions from the NFS server? i.e., chmod o+rx /Directory on the server?
    – muru
    Sep 22, 2014 at 9:47
  • @muru I just checked them via the NAS's web interface (I am unsure how to check them in its limited Linux interface that doesn't even have ls) and according to that there are read & write permissions on the folders for all registered users. Edit: chmod o+rx /Directory gave no output. Sep 22, 2014 at 10:01
  • chmod doesn't give output on successful execution. Try remounting now.
    – muru
    Sep 22, 2014 at 10:03
  • @muru: My mistake. I misinterpreted the command at first. So, yes, I can now access the folders, but the problem is that I would prefer not allowing everyone to read and write in that folder. I will update the question and that detail. Any suggestion how to go about that? Sep 22, 2014 at 10:14
  • Yes. chmod it back to o-rx. chown it to some group, use a GID if you prefer. Create a group of that GID on your system, and add your user and UserA to it.
    – muru
    Sep 22, 2014 at 10:15

1 Answer 1

7

Let usera be the primary group of UserA (groups usera). You can find out the GID using: id -g usera on the client system, say it is 1256. Now add your user to the usera group:

sudo adduser ayven usera

Now, on the server, do:

chown :1256 /Directory # Replace 1256 with the correct GID
chmod g+rwxs /Directory

Remount it on the client:

sudo umount /Directory
sudo mount /Directory

(You might have to relogin for your new groups to take effect.)

Now both you and usera have complete access to the NFS share. I have used the setgid bit, so you may have to enable it, I don't remember it. Add any users you wish to have access to this directory to the usera group.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .