centos8配置samba服务
2022-10-24 本文已影响0人
Aliang_
实验环境
软件:VMware Workstation 16 Pro
CentOS系统版本:CentOS-8.5.2111
终端软件:WindTerm_2.6.0
1.安装samba
yum install -y samba
image.png
2.修改samba配置文件
vim /etc/samba/smb.conf
[global]
workgroup = SAMBA
security = user
map to guest=bad user ###映射服务无法识别用户成为guset用户
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[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
###以下为自定义配置
[gongxiang] ###这里是共享目录名称
comment = tmp gongxiang ###文件描述
path = /gongxiang/ ###共享文件路径(绝对路径)
writeable = yes ###设置所有用户允许写入
browseable = yes ###设置用户能在浏览器看到目录
guest ok = yes ###允许匿名登录
netbios name =gongxiang ###设置服务主机名
3.创建文件夹
mkdir /gongxiang/
4.更改文件访问权限
chmod -R 777 /gongxiang/
chcon -R -t public_content_rw_t /gongxiang/
4.清空防火墙规则
iptables -F
5.打开SELinux的samba配置布尔值
setsebool samba_enable_home_dirs on
6.关系防火墙和SELinux
systemctl stop firewalld.service
setenforce 0
7.启动samba服务
systemctl start smb
8.查看smb所需的端口是否全部打开
netstat -tualp | grep smb
image.png
9.测试
打开 运行 输入\samba服务器IP
image.png
注意:如果提示需要用户名密码访问则添加一个samba服务用户
useradd gongxiang
pdbedit -a -u gongxiang
image.png