CentOS 8
[1]
- Prepare the basic config by installing packages and creating a new config file.
dnf install samba samba-client samba-common -y
mv /etc/samba/smb.conf /etc/samba/smb.conf.bkp
- Add the following to the file.
[global]
workgroup = WORKGROUP
server string = MAST_SHARE
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ==============================
- If the users have not been created, create them now.
- Add the users as samba users.
passwd user1
Changing password for user user1.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
- In this example, I want to share a directory with several people. I create a group and add the users to it, then grant this group writes to the directory.
- Also add selinux permissions.[2]
groupadd group1
usermod -a -G group1 user1
usermod -a -G group1 user2
chown -R user1:group1 /data/share1
chmod -R 0770 /data/share1
setsebool -P samba_export_all_ro=1 samba_export_all_rw=1
semanage fcontext -a -t samba_share_t "/data/share1(/.*)?"
restorecon -R /data/share1
[share1]
path = /data/share1
valid users = @group1
guest ok = no
writable = yes
browsable = yes
systemctl enable --now smb.service
systemctl enable --now nmb.service
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
Amazon Linux 2
sudo yum install samba samba-client samba-common -y