User Tools

Site Tools


server:samba_windows_share_multiuser

This is an old revision of the document!


Setup a SMB Share with Multiple Users

Samba is a free software re-implementation of the SMB/CIFS networking protocol. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain.

With this guide you will be able to create a SMB share with multiple users who can see and modify the files of other users without permissions issues. This can of course be changed so that only the individual users can see and modify their own files.

Setup SMB share

Installation

First install the samba package:

sudo apt install samba

The configuration files are located at /etc/samba/smb.conf

Directory Setup and Admin User Creation

This will be the base directory for directory containing the users folder. The users folder will contain all user directories.

sudo mkdir /samba
sudo chgrp sambashare /samba

This user will function as the user share admin, it is not necessary if you already have created a smb user with the same username who has sudo access. This user will not have shell access.

sudo useradd -M -d /samba/users -s /usr/sbin/nologin -G sambashare sadmin

This is where the smb password is set.

sudo smbpasswd -a sadmin

This is the users which will contain all of the user folders. We will set the permissions so that any of the members of the sambashare group will be able to view and modify files in this folder.

sudo mkdir /samba/users
sudo chown sadmin:sambashare /samba/users
sudo chmod 2770 /samba/users

Creation of Individual Users

This will create the user “user1” with the home directory /samba/users/user1, without shell access and add it to the sambashare group.

To add additional users, follow the same steps, be sure to change all of the instances of user1 to something else.

sudo useradd -M -d /samba/users/user1 -s /usr/sbin/nologin -G sambashare user1
sudo mkdir /samba/users/user1
sudo chown user1:sambashare /samba/users/user1
sudo chmod 2770 /samba/users/user1
sudo smbpasswd -a user1
sudo smbpasswd -e user1

/etc/smb/smb.conf

[users]
    path = /samba/users
    browseable = yes
    read only = no
    force create mode = 0660
    force directory mode = 2770
    valid users = @sambashare @sadmin

[user1]
    path = /samba/users/user1
    browseable = no
    read only = no
    force create mode = 0660
    force directory mode = 2770
    valid users = user1 @sadmin
    
#[user2]
#    path = /samba/users/user2
#    browseable = no
#    read only = no
#    force create mode = 0660
#    force directory mode = 2770
#    valid users = user2 @sadmin

Usage on Windows

On Windows, each user folder can be accessed and mapped by \\x.x.x.x\<user>

This way each user can have direct access to their user folder from Windows Explorer.

To access the root directory, any user can simply go to \\x.x.x.x to see the user share and view other folders.

server/samba_windows_share_multiuser.1639228355.txt.gz · Last modified: 2021/12/11 13:12 by lucid