安装 Samba 1 sudo yum -y install samba samba-client samba-common
检查是否安装成功
Configure Samba ShareName Path Rights SHAREDOCS /smb/docs All include guest RDDOCS /smb/tech Only users in group
创建共享目录 1 2 sudo mkdir -p /smb/docs sudo mkdir -p /smb/tech
创建用户 1 2 sudo useradd cosmo sudo useradd RD
修改用户组 1 sudo usermod -a-G RD cosmo
检查用户组
创建Samba用户
修改目录权限 1 2 3 4 5 6 sudo chgrp RD /smb/tech sudo chgrp RD /smb/docs sudo chown RD /smb/tech sudo chown RD /smb/docs sudo chmod 770 /smb/tech sudo chmod 777 /smb/docs
检查权限
备份原有配置文件 1 sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.origin
修改配置文件 1 sudo vim /etc/samba/smb.conf
—–/etc/samba/smb.comf—–
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [global] workgroup = WorkGroup netbios name = File Sever server string = Samba Server Version %v security = user map to guest = Bad User# 如果出现Failed to retrieve printer list: NT_STATUIS_UNSUCCESSFUL错误 ;printing = bsd ;printcap name = /dev/null [SHAREDOCS] path = /smb/docs readonly = yes broseable = yes guest ok = yes [RDDOCS] path = /smb/tech public = no writable = yes write list = @RD valid user = @RD
重启服务 1 2 3 4 sudo systemctl restart smb sudo systemctl enable smb sudo systemctl reload smb sudo systemctl status smb
防火墙开放端口 1 2 3 4 5 6 7 8 # For Firewall sudo firewall-cmd --permanent --zone=public --add-service=samba# For iptables # iptables -A INPUT -p tcp -m multiport --dports 139,445 -j ACCEPT iptables -A INPUT -p udp -m multiport --dports 137,138 -j ACCEPT# iptables -A OUTPUT -p tcp -m multiport --sports 139,445 -j ACCEPT iptables -A OUTPUT -p tcp -m multiport --sports 137,138 -j ACCEPT
需要关闭 SELinux 1 2 3 sudo vim /etc/selinux/config selinux=disabled ####### sudo reboot
联通测试 Linux 1 smbclient -L localhost -U cosmo