Results 1 to 8 of 8

Thread: shared directory between 2 users with Samba/cifs

  1. #1
    Join Date
    Apr 2007
    Location
    Raleigh, NC, USA
    Beans
    162

    shared directory between 2 users with Samba/cifs

    I have 2 user account on a desktop and I want them both to have access to a smb share on a server. Currently I can't seem to get the share mounted so the permissions are right.

    Both my users are a member of group 'users'
    I uses smbpasswd -a for both users
    My smb.conf for the share is:

    [Anonymous]
    path = /mnt/md0/samba/anonymous
    browsable =yes
    writable = yes
    guest ok = yes
    read only = no
    force group = users
    force user = jim
    create mask = 0774
    force directory mode = 2775

    However, the other user (not jim) can't write on the share.

    The desktop with the problem for the second user has a fstab as follow:
    //192.168.0.250/public /mnt/public cifs defaults,user=jim,password=123456,uid=jim,gid=user s
    //192.168.0.250/anonymous /mnt/anonymous cifs defaults,user=jim,password=123456,uid=jim,gid=user s

    What am I missing?

  2. #2
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: shared directory between 2 users with Samba/cifs

    Answering this... but have lots to type... Will add it as an edit to another post.
    Last edited by MAFoElffen; June 12th, 2021 at 03:46 AM.

    Concurrent coexistance of Windows, Linux and UNIX...
    Ubuntu user # 33563, Linux user # 533637
    Sticky: [all variants] Graphics Resolution- Upgrade /Blank Screen after reboot
    UbuntuForums system-info Script

  3. #3
    Join Date
    Mar 2010
    Location
    USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: shared directory between 2 users with Samba/cifs

    You have it configured it locked down to just the one user... When you said, force user = Jim, then it limited to just Jim.

    Let me walk you through that as summarized...
    Code:
    # Creating the share called "anonymous".
    
    
    sudo mkdir -p /mnt/md0/samba/anonymous
    
    # Create the group users
    sudo groupadd users
    
    
    # Change the group ownership and permissions of the directory
    sudo chgrp users /mnt/md0/samba/anonymous
    ​sudo chmod -R 770 /mnt/md0/samba/anonymous
    
    
    # Add users to the group in the system
    sudo usermod -a -G users Jim
    sudo usermod -a -G users Jane
    
    
    # Add the users to Samba
    sudo smbpasswd -a Jim
    ​sudo smbpasswd -e Jane
    If Samba security is set to allow verified users who used system credentials, then you don't need that last part... But you did say you locked it down to two users...

    The in the Samba Config:
    Code:
    [global}
    ​workgroup = WORKGROUP
    ​server string = Name_Of_Server
    ​netbios name = Ubuntu
    ​security = user
    ​map to guest = bad user
    ​dns proxy = no
    
    
    #### SHARES ####
    [anonymous]
    ​path = /mnt/md0/samba/anonymous
    ​browsable = yes
    ​writable = yes
    ​guest ok = yes
    ​read only = no
    ​valid users = @users
    At least, that is "one way" to set up groups to a Samba Share.

    Personally, I would use a group name that is not as close to a system type of name. "users" is, well... LOL
    Last edited by MAFoElffen; June 12th, 2021 at 03:52 AM.

    Concurrent coexistance of Windows, Linux and UNIX...
    Ubuntu user # 33563, Linux user # 533637
    Sticky: [all variants] Graphics Resolution- Upgrade /Blank Screen after reboot
    UbuntuForums system-info Script

  4. #4
    Join Date
    Apr 2007
    Location
    Raleigh, NC, USA
    Beans
    162

    Re: shared directory between 2 users with Samba/cifs

    I seem to have made it worse. I made some changes to my smb.conf based on you response and now even the owner 'jim' can't list the directory. I commented out the force and added the valid users. Then restarted smbd and nmbd . Here's the conf file:
    Code:
    [Anonymous]
    path = /mnt/md0/samba/anonymous
    browsable =yes
    writable = yes
    guest ok = yes
    read only = no
    #force group = users
    #force user = jim
    #create mask = 0774
    #force directory mode = 2775
    valid users = @users
    I tried unmounting the share and when I tried to remount it I see this error in dmesg:

    [35166.414246] CIFS: Attempting to mount //192.168.0.250/anonymous
    [35166.425319] CIFS: VFS: cifs_mount failed w/return code = -13

  5. #5
    Join Date
    Apr 2007
    Location
    Raleigh, NC, USA
    Beans
    162

    Re: shared directory between 2 users with Samba/cifs

    Let me add that the goal here is to allow any users (of which there are only 2) to read and write to a smb share on a ubuntu server. If I need to create a complete new share pointing to the same directory on the server that is fine as well.

  6. #6
    Join Date
    Dec 2009
    Beans
    6,556

    Re: shared directory between 2 users with Samba/cifs

    Just so I understand: This is how your share was created originally:
    [Anonymous]
    path = /mnt/md0/samba/anonymous
    browsable =yes
    writable = yes
    guest ok = yes
    read only = no
    force group = users
    force user = jim
    create mask = 0774
    force directory mode = 2775
    And you are connecting to the share with this mount declaration on the client - can't seem to get rid of that space between user and s in the quote for some reason:
    //192.168.0.250/anonymous /mnt/anonymous cifs defaults,user=jim,password=123456,uid=jim,gid=user s
    That mount declaration will create a mount of that share with permissions that look like this on the client:
    drwxr-xr-x 2 jim users
    That mounted share is owned and writeable only to jim - on the client.

    This will make it so every user - at least every user who is a member of the "users" group on the client - can write to the share:
    Code:
     //192.168.0.250/anonymous /mnt/anonymous cifs defaults,user=jim,password=123456,uid=jim,gid=users,dir_mode=0775,file_mode=0664 0 0
    Now your mount will have permissions that look look this:
    drwxrwxr-x 2 jim users
    Last edited by Morbius1; June 12th, 2021 at 12:57 PM.

  7. #7
    Join Date
    Apr 2007
    Location
    Raleigh, NC, USA
    Beans
    162

    Re: shared directory between 2 users with Samba/cifs

    Thank you, that worked. but I'm not sure I understand why I need to read up on samba/cifs. So many of the references I found are either too complicated or too simple.

  8. #8
    Join Date
    Dec 2009
    Beans
    6,556

    Re: shared directory between 2 users with Samba/cifs

    I think the issue for some users is a conceptual one.

    Samba uses a Client-Server model to do its thing.

    A server never ever exposes the internal permissions of it's assets to the client. And the client never never never ever has any control over the permissions on the server. But each one is free to do whatever it wants on it's own end.

    When you do a cifs mount of a share you are creating on the client a "view" of that share with ownership and permissions that pertain to that client. For your particular mount expression you are passing to the server a username ( jim ) and password. From that moment on "jim" is the only user the server sees. It doesn't even know the other users on the client exist.

    But on the client you can have this share accessible by as many as you want: Only to jim the way it was before, To all members of the "users" group which is what you have now, or to every user on the client ( dir_mode=0777,file_mode=0666 ). To the server they are all "jim".
    Last edited by Morbius1; June 12th, 2021 at 02:01 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •