Debian 11 Bullseye
Sponsored Link

Samba : Limited Shared Folder
2021/09/14
 
Install Samba to Configure File Server.
For example, Create a shared Folder that users in [smbgroup01] group can only access to shared folder [/home/share01] and also they are required user authetication.
[1] Install and Configure Samba.
root@smb:~#
apt -y install samba
root@smb:~#
groupadd smbgroup01

root@smb:~#
mkdir /home/share01

root@smb:~#
chgrp smbgroup01 /home/share01

root@smb:~#
chmod 770 /home/share01

root@smb:~#
vi /etc/samba/smb.conf
[global]
   # line 25 : add (set charset)
   unix charset = UTF-8
   dos charset = CP932

   # line 30 : confirm (Windows default)
   workgroup = WORKGROUP

   # line 37 : uncomment and add network you allow to access
   interfaces = 127.0.0.0/8 10.0.0.0/24

   # line 98 : comment out and add the line below
   #map to guest = bad user
   security = user

.....
.....

# add to the end
# any Share name you like
[Share01]
   # specify shared directory
   path = /home/share01
   # allow writing
   writable = yes
   # not allow guest user (nobody)
   guest ok = no
   # allow only [smbgroup01] group
   valid users = @smbgroup01
   # set permission [777] when file created
   force create mode = 777
   # set permission [777] when folder created
   force directory mode = 777
   # inherit permissions from parent folder
   inherit permissions = yes 

root@smb:~#
systemctl restart smbd

# add Samba user

root@smb:~#
adduser debian

root@smb:~#
smbpasswd -a debian

New SMB password:    
# set passwords

Retype new SMB password:
Added user debian.
root@smb:~#
usermod -G smbgroup01 debian

Matched Content