安装、简单配置
yum install samba
# 开机自启
systemctl enable smb
准备
# 新建共享文件夹或使用已有的文件夹
mkdir /sharedPath
# SELinux上下文及布尔值
semanage fcontext -a -t samba_share_t '/sharedPath(/.*)?'
restorecon -vvFR /sharedPath
# 查看
ls -Zd /sharedPath
# 准备用户
useradd -s /sbin/nologin smbd
# 设置用户密码
smbpasswd -a smb
配置
# 配置文件位置 /etc/samba/smb.conf
# 先备份
cd /etc/samba/
cp smb.conf smb.conf.bak
# 安装vim编辑器
yum install vim -y
# 编辑配置文件
vim smb.conf
[global]
workgroup = WORKGROUP
# 使用有效用户名密码登录
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[mysql]
# 注释
comment = Mysql Lib
# 共享路径
path = /var/lib/mysql
# 可写
writable = yes
# 允许用户
valid users = smb
# 创建文件默认权限
create mask = 0777
# 创建文件夹默认权限
directory mask = 0777
# 测试配置
testparm
# 启动samba
systemctl start smb
安全,无防火墙、SELinux可忽略
# 打开防火墙端口
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
# SELinux配置,暂时关闭,后续增加
setenforce 0
网友评论