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.

[[email protected] ~]# dnf install samba samba-client -y
[[email protected] ~]# groupadd security
[[email protected] ~]# chgrp security /home/security
[[email protected] ~]# chmod 770 /home/security
[[email protected] ~]# 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

[[email protected] ~]# systemctl enable smb
[[email protected] ~]# systemctl start smb

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

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

[[email protected] ~]# firewall-cmd --permanent --add-service=samba
success
[[email protected] ~]# firewall-cmd --reload
success

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

[[email protected] ~]# setsebool -P samba_enable_home_dirs on
[[email protected] ~]# restorecon -R /home/share