Restricted Accessed Share

Install Samba to build a File Server. For example, Create a shared Folder which requires user authentication.

[1] Install and Configure Samba.

[root@futurelinux ~]# dnf install samba samba-client -y
[root@futurelinux ~]# groupadd security
[root@futurelinux ~]# chgrp security /home/security
[root@futurelinux ~]# chmod 770 /home/security
[root@futurelinux ~]# vi /etc/samba/smb.conf

# line 7: change (Windows default)
workgroup = WORKGROUP

# add to the end
# any Share name you like
[Security]
        path = /home/security
        writable = yes
        create mode = 0770
        directory mode = 0770
        # not allow guest user
        guest ok = no
        # allow only security group
        valid users = @security
        directory mode = 0777

[root@futurelinux ~]# systemctl enable smb
[root@futurelinux ~]# systemctl start smb

# add a user in Samba
[root@futurelinux ~]# useradd future
[root@futurelinux ~]# smbpasswd -a future
New SMB password:     # set password
Retype new SMB password:
Added user future.
[root@futurelinux ~]# usermod -G security future

[2] If Firewalld is running, allow Samba service.

[root@futurelinux ~]# firewall-cmd --permanent --add-service=samba
success
[root@futurelinux ~]# firewall-cmd --reload
success

[3] If SELinux is enabled, change SELinux Context.

[root@futurelinux ~]# setsebool -P samba_enable_home_dirs on
[root@futurelinux ~]# restorecon -R /home/share