Difference between revisions of "Basic SAMBA Configuration"

From Michael's Information Zone
Jump to navigation Jump to search
Line 60: Line 60:
 
<pre>
 
<pre>
 
sudo yum install samba samba-client samba-common -y
 
sudo yum install samba samba-client samba-common -y
 +
 +
</pre>

Revision as of 12:50, 31 August 2020

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
  • Update the samba config.
[share1]
path = /data/share1
valid users = @group1
guest ok = no
writable = yes
browsable = yes
  • Enable services
systemctl enable --now smb.service
systemctl enable --now nmb.service
  • Update firewall rules
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload

Amazon Linux 2

sudo yum install samba samba-client samba-common -y