案例二、公司现有多个部门,因工作需要,将TS部的资料存放在samba服务器的/ts 目录中集中管理,以便TS人员浏览,并且该目录只允许TS部员工访问。
a. 添加TS部组和用户
建立用户的同时加入到相应的组中的方式:useradd -g 组名 用户名
b. 在根目录下建立/ts 文件夹
c. 将刚才建立的两个帐户添加到samba的账户中
d. 修改主配置文件如下:
#======================= Global Settings ===================================== [global] # ----------------------- Network Related Options ------------------------- # # workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH # # server string is the equivalent of the NT Description field # # netbios name can be used to specify a server name not tied to the hostname workgroup = WORKGROUP server string = David Samba Server Version %v netbios name = DavidSamba # --------------------------- Logging Options ----------------------------- # # Log File let you specify where to put logs and how to split them up. log file = /var/log/samba/log.%m # ----------------------- Standalone Server Options ------------------------ # # Scurity can be set to user, share(deprecated) or server(deprecated) security = user //用户级别,由提供服务的Samba服务器负责检查账户和密码 #============================ Share Definitions ============================== [homes] //设置用户宿主目录 comment = Home Directories browseable = no writable = yes ; valid users = %S ; valid users = MYDOMAIN\%S [public] comment = Public Stuff path = /share public = yes [ts] //ts 组目录,只允许ts组成员访问 comment = TS path = /ts valid users = @ts
e. 重新加载配置
f. 到windows客户端验证,访问\\10.0.0.163,提示输入用户名和密码,在此输入sandy验证,如下图:
g. 访问成功,可以看到公共的public目录,用户sandy的宿主目录,和其有权限访问的ts目录
h. 进入ts目录,有刚才创建的newyork.city文件