安装 samba 及其依赖包
[root@samba-server ~]# yum install samba samba-client samba-common -y
[root@samba-server ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@samba-server ~]# 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 = WORKGROUP
security = user
passdb backend = tdbsam
#hosts allow = 10.0.2..0/255.255.255.0,172.17.0.0/255.255.0.0
netbios name = ponfey-smb
log file = /var/log/samba/log.%U_%I
log level = 3
[Devops]
path =/samba/Devops/
public = no
valid users = devops
#printable = no
writable = yes
#read list = test
create mode = 0777
force create mode = 0777
directory mode = 0777
force directory mode = 0777
# browseable = no
vfs object = recycle
recycle:keeptree = Yes
recycle:repository = .delete/%U_%I
recycle:versions = Yes
创建共享主目录文件
[root@samba-server ~]# mkdir -p /samba/Devops/
[root@samba-server ~]# groupadd devops_group
[root@samba-server ~]# useradd devops -G devops_group
[root@samba-server ~]# smbpasswd -a devops
配置开机启动smb和nmb 服务
[root@samba-server ~]# systemctl enable smb.service
[root@samba-server ~]# systemctl enable nmb.service
重启smb和nmb 服务
[root@samba-server ~]# systemctl restart smb.service
[root@samba-server ~]# systemctl restart nmb.service
防火墙相关配置:
[root@samba-server ~]# firewall-cmd --permanent --zone=public --add-service=samba
[root@samba-server ~]# firewall-cmd --reload
配置共享文件权限:
[root@samba-server ~]# cd /samba
[root@samba-server samba]# chmod -R 0777 /samba/Devops/
[root@samba-server samba]# chown -R devops:devops_group /samba/Devops/
[root@samba-server samba]# chcon -t samba_share_t /samba/Devops/ # 仅在开启SELinux情况下修改安全上下文的类型字段