#########################samba应用案例
#项目需求:
NB是一家网站设计公司,有四个部门分别是商务部、页面设计部、开发部、运维部.四个部门紧密联系,部门之间有大量的数据需要共享,,为加强部门之间的互联互通,NB决定部署Samba服务器,满足部门之间可以快速共享数据的要求,实现流水线办公流程
(1)创建目录结构
满足NB公司要求,建立5个一级目录和4个部门共享目录,4个部门共享目录用于部门内部员工共享数据,每个部门员工可以在相应的部门共享目录下创建自己的目录和文件,另一个公共共享目录下建立四个共享目录,用于所有部门共享彼此的数据
[root@se1 ~]# mkdir -p /NB/{sales,design,develop,ops,share/{design,sales,develop,ops}}
[root@se1 ~]# tree /NB (tree-1.6.0-10.el7.x86_64 : File system tree viewer)
/NB
├── design
├── develop
├── ops
├── sales
└── share
├── design
├── develop
├── ops
└── sales
(2)添加账户
出于安全,设置访问共享时使用账户和密码.初始状态下,为每个部门创建两个用户,并创建所有共享目录的管理员,方便后期操作,编写脚本如下:
#!/bin/bash
#add user for share
depart=(sales design develop ops)
for g in ${depart[@]}
do
groupadd $g
for u in $(seq 2)
do
useradd -M -s /sbin/nologin -g ${g} ${g}$u
done
done
#smbpasswd -a sales1
#smbpasswd -a sales2
#smbpasswd -a ops1
#smbpasswd -a ops2
#smbpasswd -a dev1
#smbpasswd -a dev2
#smbpasswd -a design1
#smbpasswd -a design2
(3)修改配置文件
[global]
workgroup = STAFF
server string = NB.corp share
passdb backend = tdbsam
load printers = yes
cups options = raw
log file = /var/log/samba/log.%m
[homes]
comment = Home Directories
browseable = No
writable = yes
[sales]
comment = sales share
path = /NB/sales
browseable = yes
guest ok = no
writable = no
write list = @sales
read only = yes
[design]
comment = design share
path = /NB/design
browseable = yes
guest ok = no
writable = no
write list = @design
[develop]
comment = develop share
path = /NB/develop
browseable = yes
guest ok = no
writable = no
write list = @develop
[ops]
comment = ops share
path = /NB/ops
browseable = yes
guest ok = no
writable = no
write list = @ops
[share]
comment = common share
path = /NB/share
browseable = yes
guest ok = no
writable = no
(4)修改权限
#chmod 1770 /NB/{design,develop,ops,sales,}
#chmod 1777 /NB/share
#chown :design /NB/design
#chown :develop /NB/develop
#chown :ops /NB/ops
#chown :sales /NB/sales
(5)重启服务
#systemctl restart smb
samba文件共享(二)
最新推荐文章于 2023-08-14 14:40:27 发布