centos samba搭建
1.需求:
建立两个用户(zx,zxadmin),zxadmin能访问所有目录,zx只能访问指定目录。
2.安装smb
[root@vi /]# yum install samba -y
3.创建用户(zxamin为主账户,zx为普通账户,zx属于zxadmin组),并把账户转化为smb用户
[root@vi /]# useradd zxadmin
[root@vi /]# useradd -G zxadmin zx
[root@vi /]# smbpasswd -a zxadmin New SMB password: Retype new SMB password: Added user zxadmin. [root@vi /]# smbpasswd -a zx New SMB password: Retype new SMB password: Added user zx.
4.创建smb目录(smb目录属于zxadmin用户,并且设置smb目录权限为770)
[root@vi /]# mkdir /data
[root@vi data]# mkdir /data/smb1
[root@vi data]# mkdir /data/smb2
[root@vi /]# chown -R zxadmin.zxadmin /data/
[root@vi /]# chmod -R 770 /data/
5.配置smb.conf(vim /etc/samba/smb.conf)
[smb1] comment = smb1 path = /data/smb1 browseable = yes valid users = zxadmin #指定zxadmin账户,此目录只能zxadmin访问 guest ok = no writable = yes [smb2] comment = smb2 path = /data/smb2 browseable = yes valid users = zxadmin,zx #指定zx和zxadmin账户,此目录为公用目录 guest ok = no writable = yes
6.启动smb服务
[root@vi samba]# /etc/init.d/smb start
Starting SMB services: [ OK ]
7.关闭防火墙和selinux
8.访问测试