Fedora 30
Sponsored Link

Samba : Restricted Shared Folder2019/05/14

 
Install Samba to build a File Server.
For example, Create a shared Folder which requires user authentication.
[1] Install and Configure Samba.
[root@smb ~]#
dnf -y install samba samba-client
[root@smb ~]#
groupadd security

[root@smb ~]#
mkdir /home/security

[root@smb ~]#
chgrp security /home/security

[root@smb ~]#
chmod 770 /home/security

[root@smb ~]#
vi /etc/samba/smb.conf
# line 7: add

unix charset = UTF-8
dos charset = CP932
# line 9: change (Windows default)

workgroup =
WORKGROUP
# line 11: add (IP addresses you allow to access)

hosts allow = 127. 10.0.0.
# 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

[root@smb ~]#
systemctl start smb

[root@smb ~]#
systemctl enable smb

# add a user in Samba

[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 security fedora

[2] If Firewalld is running, allow Samba service.
[root@smb ~]#
firewall-cmd --add-service=samba --permanent

success
[root@smb ~]#
firewall-cmd --reload

success
[3] If SELinux is enabled, change SELinux Context.
[root@smb ~]#
setsebool -P samba_enable_home_dirs on

[root@smb ~]#
restorecon -R /home/security

[4] It's the way to access to the shared folder. This example is on Windows 10.
Select [Computer] - [Network] - [Map Network Drive].
[5] Specify the shared folder's place in Folder section and Click the [Finish] button to enter.
[6] Authentication is required, Input the username and password you added in Samba.
[7] Just accessed.
Matched Content