1、關閉防火牆
# service iptables status //檢視防火牆的狀态
# service iptables stop //停止防火牆
# chkconfig iptables off //永久關閉防火牆
2、關閉SELINUX
# sestatus //檢視selinux狀态
# setenforce //臨時關閉SeLinux
永久關閉SeLinux,需要修改配置檔案/etc/selinux/config,将SELINUX置為disabled,然後重新開機系統。
3、安裝samba
# yum install samba samba-client samba-common -y
4、備份已有配置 # mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
添加新的配置
# vim /etc/samba/smb.conf
輸入以下内容:
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = centos
security = user
map to guest = bad user
dns proxy = no
#============================ Share Definitions ==============================
[Public]
path = /home/zyc/share
writable = yes
browsable = yes
guest ok = yes
guest only = yes
create mode = 0777
directory mode = 0777
注意:在samba4中 share 和 server已經被禁用,需要用 security = user 和map to guest =Bad User來實作無密碼通路目錄
5、為samba服務建立使用者、屬組以及修改權限、開機啟動
# groupadd smb
# useradd smb -d /home/smb/ -g smb -s /sbin/nologin
# chown -R smb:smb /home/smb/
# smbpasswd -a smb
# chkconfig nmb on
# chkconfig nmb on
6、啟動服務
# /etc/init.d/smb start
# /etc/init.d/nmb start
7、驗證:WINDOWS輸入 \\伺服器IP 通路
為便于之後通路,可映射到網絡驅動器...,如下圖所示:

參考:
https://www.cnblogs.com/hnxxcxg/p/6841778.html
https://blog.csdn.net/qq_35590198/article/details/78991207
https://blog.csdn.net/long690276759/article/details/54755400
https://www.cnblogs.com/muscleape/p/6385583.html