1、安装samba
yum install -y samba
2、修改samba配置文件
- 删除[home]配置
- 添加[share]配置
- 777权限是使个用户间创建的文件夹可互相访问,后面有对修改删除的设置
vi /etc/samba/smb.conf
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[share] # 添加此部分配置
path = /sharing
public = Yes
browseable = Yes
writable = Yes
read only = No
guest ok = No
create mask = 0777
directory mask = 0777
3、穿件目录,赋予权限
mkdir /sharing
chmod -R 777 /sharing
chmod -R o+t /sharing
4、创建用户
useradd -M -s /sbin/nologin usr1
useradd -M -s /sbin/nologin usr2
# 将用户添加到 samba
smbpasswd -a user1
smbpasswd -a user2
# 添加 Samba 用户帐号
smbpasswd -a sambauser
# 禁用 Samba 用户帐号
smbpasswd -d sambauser
# 启用 Samba 用户帐号
smbpasswd -e sambauser
# 删除 Samba 用户帐号
smbpasswd -x sambauser
5、启动服务
# 配置firewalld防火墙允许Samba服务
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
# 修改共享目录的selinux安全上下文
semanage fcontext -a -t samba_share_t /sharing
restorecon -Rv /sharing
# 附关闭selinux命令
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
# 启动samba服务
systemctl start smb
6、win0配置“添加一个网络位置”,输入:\ip\share,确定即可
image.png
参考链接:
https://cloud.tencent.com/developer/article/1722199
https://codeantenna.com/a/r0SbAXxWbU
https://blog.51cto.com/yttitan/2382465