Samba : Limited Shared Folder2021/05/20 |
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 ~]#
[root@smb ~]# dnf -y install samba 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 11 : add (set charset) unix charset = UTF-8 # change (Windows default) workgroup = WORKGROUP security = user # add (IP addresses you allow to access) hosts allow = 127. 10.0.0. ..... ..... # 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 enable --now smb # add Samba user [root@smb ~]# useradd fedora [root@smb ~]# smbpasswd -a fedora New SMB password: # set password Retype new SMB password: Added user fedora. [root@smb ~]# usermod -aG smbgroup01 fedora |
[2] | If SELinux is enabled and also use [/home] like this example, Change SELinux policy. |
[root@smb ~]# setsebool -P samba_enable_home_dirs on [root@smb ~]# restorecon -R /home/share01 |
[3] | If Firewalld is running, allow Samba service. |
[root@smb ~]# firewall-cmd --add-service=samba --permanent success [root@smb ~]# firewall-cmd --reload success |
Sponsored Link |