Search code examples
linuxsftpsambauser-permissionscentos6.5

CentOS permissions, folders, users and groups


I am new to Linux and trying to understand permissions for use with remote and local users as well as Samba. I am running a headless CentOS 6.5 server. I will try and explain my problem as clear as I can.

I have 2 remote users connecting to a folder using sftp, R_User_1 and R_User_2. I have 1 local user connecting to the same folder using samba over the local network and one root user.

I have a /home for each user that has folder_1 and folder_2. Folder_1 is a bind mount of another folder using this line in fstab:

/dev/sda2               /media/storage         ext4    defaults        0 1
/media/storage/folder_1  /home/R_User_1/folder_1     none    bind            0 0

R_User_1 and R_User_2 both need to have read only access to folder_1 but the local samba user needs to have full access as does root.

Folder_2 is placed in the users home directory and both R_User_1 and R_User_2 need full access to their own folders within the home directory as does root but not the local user.

My question is how do I go about setting up all the permissions for this so that it all works? I have the users home directories owned by root so that the remote users can not leave their home directory, this is important.

If someone could please help me I would be very grateful.

Cheers

Blinky


Solution

  • Your setup is mixing a number of things that complicate what you are trying to do. First, if you have chrooted the users to /home/user_x, then you are working against what samba is generally designed to do. Primarily, you define a share (a directory somewhere) and then control access by your share definition in /etc/samba/smb.conf (or /etc/smb.conf). Your easiest solution is to setup /home/shared and make folder_1 and folder_2 subdirs of shared (or whatever you want to call it). Then make R_User_1 & R_User_2 members of a unix group (say rusers). Allow rusers access to shared.