用YUM安裝Samba
yum install samba samba-client samba-common -y
Samba的設定檔/etc/samba/smb.conf,加入以下內容:
[global]
workgroup = MYGROUP
server string = Samba Server %v
netbios name = centos_7
security = user
map to guest = bad user
dns proxy = no
[Secure]
path = /home/share_dir
valid users = @smbgrp
guest ok = no
writable = yes
browsable = yes
儲存檔案後啟動Samba,及設定開機自動啟動:
mkdir -p / samba / anonymous
systemctl enable smb
systemctl enable nmb
systemctl restart smb
systemctl restart nmb
設定Samba對外開放與權限:
firewall -perd-service = samba
firewall-cmd -reload
mkdir / home / share_dir
chown -R smb_user:smbgrp / home / share_dir
chmod -R 0770 / home / share_dir
chcon -t samba_share_t / home / share_dir
建立Samba帳密
useradd smb_user
groupadd smbgrp
usermod -a -G smbgrp smb_user
smbpasswd -a smb_user