NAS Share Integration

I successfully integrated my NAS following the instructions (Cannot connect to NAS drives/shares - #2 by swarfendor437). However, I now need to set up a second user on the computer. This user should be able to access the same NAS shares (rw).

Since this user has a different user and group ID and cannot access the credentials file, I'm not sure what to do.

mount -t cifs //nas_ip/share_name /media/share -o credentials=~/.smbcredentials,uid=1000,gid=1000,vers=2.0

Is there a solution for beginners?

Hi Marcello, hope you are well.

I used Brave A.I. for your query which came back with:

NAS Share User Permissions

To set up a second user with read-write (RW) access to a NAS share without being in the same group, you can configure the share settings to grant specific permissions to that user. Here's how you can achieve this:

  1. Create a new user : In the NAS administration interface, create a new user account for the second user. Ensure that the user has the appropriate authentication settings enabled, such as Samba authentication.
  2. Create a new group (optional) : If you want to manage multiple users with similar access requirements, you can create a new group and add the second user to it. However, if the user needs unique permissions, you can skip this step and assign permissions directly to the user.
  3. Configure the share settings : Navigate to the share settings for the specific folder or dataset you want to grant access to. In the permissions section, you can specify which users or groups have access to the share. To grant the second user RW access, select the user and set their permissions to "Read/Write".
  4. Set file system permissions : In addition to share-level permissions, you may need to adjust the file system permissions to ensure that the second user has the necessary access to the files and folders within the share. This can be done through the NAS administration interface or using command-line tools if available.

By following these steps, you can grant a second user RW access to a NAS share without requiring them to be in the same group as other users. This approach allows for more granular control over user access and ensures that each user has the appropriate level of access to the shared resources.

AI-generated answer. Please verify critical facts.


🌐
forum.qnap.com
User-made Shares only Appear if "Everyone" Group has R0/RW - QNAP NAS Community Forum (Shutting Down Soon)

🌐
community.netgear.com
Shares user and and group permissions - NETGEAR Communities

🌐
truenas.com
NFS share, multiple users, different access rights | TrueNAS Community

🌐
truenas.com
how do I set up a multi-user

Perhaps I didn't formulate it clearly. I don't have a problem on the NAS but on the Zorin computer. I have two users and cannot handle the different user-id in the fstab.

Does this help? (Brave A.I. result.)

Control NAS Access via FSTAB

To control user access to a NAS via FSTAB settings, you can use various options in the /etc/fstab file to specify user and group permissions, as well as access controls. Here are the key methods:

  1. Using uid and gid : You can specify the user ID (uid) and group ID (gid) to control ownership of the mounted filesystem. This allows you to set the owner and group of the mounted directory to a specific user and group. For example:
//192.168.1.100/share /mnt/network_drive cifs credentials=/home/your_username/.smbcredentials,iocharset=utf8,sec=ntlm,uid=1000,gid=1000 0 0

This ensures that the mounted directory is owned by the user with uid 1000 and group with gid 1000.

  1. Using umask : For filesystems that do not support traditional Unix permissions (like FAT or NTFS), you can use the umask option to set the default permissions. For example:
/dev/sdb1 /media/workspace auto defaults,uid=1000,gid=1000,umask=022 0 1

This sets the permissions so that the owner has read, write, and execute access, while the group and others have read and execute access.

  1. Using chown and chmod : After mounting, you can use chown and chmod to change the ownership and permissions of the mounted directory. For example:
sudo chown -R user:group /mnt/network_drive
sudo chmod -R 755 /mnt/network_drive

This changes the ownership to a specific user and group and sets the permissions to allow read, write, and execute for the owner, and read and execute for others.

  1. Using ACLs (Access Control Lists) : For more granular control, you can use ACLs to set specific permissions for users and groups. This is particularly useful for filesystems that support ACLs. For example:
setfacl -m u:user:rwx /mnt/network_drive
setfacl -m g:group:rwx /mnt/network_drive

This sets read, write, and execute permissions for a specific user and group.
5. Restricting access through a subdirectory : You can create a subdirectory within the mount point and set permissions on that subdirectory to restrict access. For example:

mkdir -p /media/group1only/workspace
chgrp group1 /media/group1only
chmod 750 /media/group1only

This ensures that only members of the specified group can access the subdirectory.

By using these methods, you can effectively control user access to a NAS via FSTAB settings. Each method has its own use case, and the choice depends on the specific requirements and filesystem type.

AI-generated answer. Please verify critical facts.


🌐
askubuntu.com
samba - How do I mount a CIFS share via FSTAB and give full RW to Guest - Ask Ubuntu

🌐
baeldung.com
How to Configure /etc/fstab for Network Drive | Baeldung on Linux

🌐
reddit.com
r/linuxquestions on Reddit: FSTAB blues I want all users to get access to drives

🌐
reddit.com
r/synology on Reddit: Mounting via fstab on Linux- Not able to change ownership/group for read/write permissions ?

🌐
unix.stackexchange.com
permissions - Automatically mount a drive using /etc/fstab, and limiting access to all users of a specific group - Unix & Linux Stack Exchange

🌐
unix.stackexchange.com
mount - How to edit /etc/fstab properly for network drive? - Unix & Linux Stack Exchange

🌐
superuser.com
linux - Modify fstab entry

I also found this old thread on askubuntu, not sure if relevant:

https://askubuntu.com/questions/1539144/issues-with-programs-accessng-smb-nas

To have two or more users access the same directory, you'll have to use a dedicated group that those users belong to. You can create a new group with the command:

sudo addgroup <name_of_group>

And the output should come back with something like: Adding group 'nas' (GID 1001). In this case I called it "nas"; the name doesn't really matter as long as it doesn't conflict with others.

Then, update the /etc/fstab entry so that the gid matches the new group:

mount -t cifs //nas_ip/share_name /media/share -o credentials=~/.smbcredentials,uid=1000,gid=1001,vers=2.0

Just the gid will do, even if you still have to assign a uid.

To assign a user to a new group:

sudo usermod -aG <group_name> <user_name>

For example, to assign my username "zenzen" to the group "nas":

sudo usermod -aG nas zenzen

Restart the computer to be sure if applies all the ownership properly.

1 Like

Thank you, but that doesn't help. Because it doesn't solve exactly what I described. I can only enter a single uid and guid in the fstab. But on the zorin computer I have two users with different uid.
Ps. Ai answers are not useful here. Please consider how much energy such a query consumes.

But thanks, zenzen gave me some good advices.

1 Like

But you have maked Swarf's post #4 as Solution. Should it be zenzen's post #5 instead ?

You're right, I made a mistake. Swarf's posts didn't answer my questions. The post by zenzen seems to be a good suggestion. I still have to try to implement it.
Thanks for the hint

I have unmarked #4 for you, but not marked #5. I will leave that to you, if that proves to be (or points you to) the Solution.

Hello
I created a group called β€œnas” and added the two users to it. They are displayed correctly (nas:x:1002:marcel,zsuzsa
marcel@ThinkCentre-Edge72:~$ ).
I reloaded the shares with mount -a, and they are also displayed correctly in Nautilus. In the first user (marcel = admin), the data is also readable and writable.
For the second user (zsuzsa), it is only readable.
This is what fstab looks like:
//ds-marcel/music /media/music cifs users,username=yyyyyyyy,password=xxxxxxxxxxxxx=1000,gid=1002,vers=2.0,auto,rw 0 0
What could be the problem?

PS: I found some helpful documentation in the Red Hat wiki. It also explicitly refers to multi-user sharing. I will test this information and then provide feedback again.: 9.2. Mounting an SMB Share | Storage Administration Guide | Red Hat Enterprise Linux | 7 | Red Hat Documentation

This guide could also be helpful for you:

Perhaps these steps are required:

Change the group ownership for your directory with the command:

sudo chgrp nas /PATH

Change the permissions of the directory with

sudo chmod -R 770 /PATH

Then edit
/etc/samba/smb.conf
as described. Replace the valid users there with your nas group and adapt the path.

It may be a simple matter of permissions, since there's a user ownership and a group ownership which can have different access. The command to change permissions is chmod as suggested above:

chmod -R 770 /media/music

Depending on how many files you have, this may take a while since the -R option will apply these recursively to all files and folders.

In case you're wondering, 7 is a shorthand for the three basic types of permissions associated to files: read (4), write (2) and execute (1) permissions. And the triplet 770 is also a shorthand to assign these permissions to the user owner of the folder (in this case, user "marcel") the group owner (the group you created for it, "nas") and any other user not under any of these two categories. A permission level of 0 on the last digit means that none else can access these files.