建立组账户tech、创建员工账号jiashenzhen chenlongfei
[root@localhost ~]# groupadd tech
[root@localhost ~]# useradd -g tech chenlongfei
[root@localhost ~]# useradd -g tech jiashenzhen
[root@localhost ~]# useradd common
2.创建存放共享资源的文件夹/home/samba/data,以及子目录public tech jiashenzhen chenlongfei
[root@localhost share]# mkdir public tech jiashenzhen chenlongfei
[root@localhost share]# chown root:tech public
[root@localhost share]# chown root:tech tech
[root@localhost share]# chown jiashenzhen:root jiashenzhen
[root@localhost share]# chown chenlongfei:root chenlongfei
[root@localhost share]# chmod -R 700 jiashenzhen
[root@localhost share]# chmod -R 700 chenlongfei
[root@localhost share]# chmod -R 775 public
[root@localhost share]# chmod -R 770 tech
3.创建共享用户
useradd common
pdbedit -a -u common
useradd jiashenzhen
pdbedit -a -u jiashenzhen
useradd chenlongfei
pdbedit -a -u chenlongfei
useradd root
pdbedit -a -u root
[root@localhost share]# pdbedit -L(验证账户)
jiashenzhen:501:
root:0:root
chenlongfei:502:
common:503:
4.修改smb.conf文件,添加共享设置,并启动smb服务
[root@localhost share]# vi /etc/samba/smb.conf
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
config file = /etc/samba/smb.conf.%U
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
path = /home/samba/data/home
browseable = yes
writable = yes
write list = root,@tech
[public]
comment = public
path = /home/samba/data/public
browseable = yes
writable = yes
valid users = root,@tech,common
write list = root,@tech
directory mask = 774
create mask = 775
[tech]
comment = technology data
path = /home/samba/data/tech
browseable = yes
guest ok = no
writable = no
valid users = root,@tech
write list = root,@tech
directory mask = 0774
create mask = 0660
[Jiashenzhen]
comment = chenlongfei data
path = /home/samba/data/jiashenzhen
browseable = no
guest ok = no
writable = no
valid users = jiashenzhen
write list = jiashenzhen
directory mask = 0700
create mask = 0700
[chenlongfei]
comment = chenlongfei data
path = /home/samba/data/chenlongfei
browseable = no
guest ok = no
writable = no
valid users = chenlongfei
write list = chenlongfei
directory mask = 0700
create mask = 0700
子配置文件
[root@rd samba]# egrep -v "^;|#" smb.conf.jiashenzhen
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
[public]
comment = Home Directories
path = /home/samba/data/public
browseable = yes
writable = yes
valid users = root,@tech
write list = root,@tech
directory mask = 0774
create mask = 0660
[tech]
comment = technology data
path = /home/samba/data/tech
browseable = yes
guest ok = no
writable = no
valid users = root,@tech
write list = root,@tech
directory mask = 0774
create mask = 0660
[Jiashenzhen]
comment = jiashenzhen data
path = /home/samba/data/jiashenzhen
guest ok = no
writable = no
valid users = jiashenzhen
write list = jiashenzhen
directory mask = 0700
create mask = 0700
[root@rd samba]# egrep -v "^;|#" smb.conf.chenlongfei
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
[homes]
comment = Home Directories
path = /home/samba/data/home
browseable = yes
writable = yes
write list = root,@tech
[public]
comment = public
path = /home/samba/data/public
browseable = yes
writable = yes
valid users = root,@tech
write list = root,@tech
directory mask = 0774
create mask = 0660
[tech]
comment = technology data
path = /home/samba/data/tech
browseable = yes
guest ok = no
writable = no
valid users = root,@tech
write list = root,@tech
directory mask = 0774
create mask = 0660
[chenlongfei]
comment = chenlongfei data
path = /home/samba/data/chenlongfei
guest ok = no
writable = no
valid users = chenlongfei
write list = chenlongfei
directory mask = 0700
create mask = 0700
启动服务
/etc/init.d/smb start
/etc/init.d/nmb start
客户端访问:
smbclient //172.23.145.41/tech -U jiashenzhen
客户端挂载:
mount -t cifs //172.23.145.41/tech /home/172.23.145.41 -o username=jiashenzhen,password=jiashenzhen
本文出自 “jiazheming” 博客,请务必保留此出处http://8888866666.blog.51cto.com/6988153/1792530
原文地址:http://8888866666.blog.51cto.com/6988153/1792530