当前位置: > CentOS > CentOS服务器 > 文件同步 >

CentOS下Samba配置实例

时间:2014-12-03 08:59来源:linux.it.net.cn 作者:IT
环境介绍:
CentOS 6.5 x64
Samba-3.6.9


1、安装前准备

 1) selinux (或直接disable)
[root@smb ~] setsebool -P samba_enable_home_dirs on
[root@smb ~]setsebool -P samba_export_all_rw on

 2) iptables

[root@smb ~] skip...................

3)系统目录及用户与组创建 (留意大小写)
[root@smb ~] mkdir -pv /smb/{Sales,Develop,Public}
[root@smb ~] groupadd ops 
[root@smb ~] useradd -G ops -s /sbin/nologin zhang3
[root@smb ~] groupadd develop 
[root@smb ~] useradd -G develop -s /sbin/nologin li4
[root@smb ~] groupadd Boss
[root@smb ~] useradd -G Boss -s /sbin/nologin wang5
[root@smb ~] groupadd sales 
[root@smb ~] useradd -G sales -s /sbin/nologin zhao6

[root@smb ~] chmod 1777 /smb/{Sales,Develop}
[root@smb ~] chmod 1777 /smb/Public

[root@smb ~] chgrp sales /smb/Sales
[root@smb ~] chgrp develop /smb/Develop
[root@smb ~] chgrp ops /smb/Public

2、安装

[root@smb ~] yum  -y install samba samba-client      # client可以不装

 

3、配置主文件

[root@smb ~] vi /etc/samba/smb.conf

#============================= Global Setting =============================
    workgroup = WORKGROUP
        server string = Samba Server Version %v
        netbios name = SHARE FILE SERVER
        guest account = nobody
        display charset = UTF-8
        unix charset = UTF-8
        dos charset = cp936

        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
        username map = /etc/samba/smbusers

        os level = 40
        local master = yes
        preferred master = yes


;       interfaces = lo eth0 192.168.12.2/24 192.168.13.2/24
;       hosts allow = 127. 192.168.12. 192.168.13.

        max log size = 50
        security = user
        passdb backend = tdbsam
    
    cups options = raw
        disable spoolss = yes
        load printers = no
        printing = bsd
        printcap name = /dev/null


#============================= Global Setting =============================
;[homes]
;        comment = Home Directories
;        browseable = no
;        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S


[Sales]
        path = /smb/Sales
        comment = Sales Depart Share Folder
        browseable = yes
        guest ok = no
        writeable = no
        valid users = @sales, @Boss
        write list = @ sales

[Develop]
        path = /smb/Develop
        comment = Develop Depart Share Folder
        browseable = yes
        guest ok = no
        writeable = no
        valid users = @develop
        write list = @develop

[Public]
       path = /smb/Public
        comment = Public Share Folder
        browseable = yes
        guest ok = no
        writeable = no
        valid users = @develop, @Boss, @sales
        admin users = zhang3
        write list = @ops
        invalid users = root



4、添置用户及设置密码
1)通过smbpasswd
[root@smb ~] smbpasswd -a zhang3
 或
2)  通过pdbedit 
[root@smb ~] pdbedit -a li4
......以此类推......

 pdbedit –a username:新建Samba账户。 
 pdbedit –x username:删除Samba账户。 
 pdbedit –L:列出Samba用户列表,读取passdb.tdb数据库文件。 
 pdbedit –Lv:列出Samba用户列表的详细信息。 
 pdbedit –c “[D]” –u username:暂停该Samba用户的账号。 
 pdbedit –c “[]” –uusername:恢复该Samba用户的账号。 

客户端登陆状态
[root@smb ~] smbstatus

Linux 客户端连接(回车直接查看)
[root@smb ~] smbclient -L //192.168.109.237/Public

[root@smb ~] smbclient -U zhang3 //192.168.109.237/Public
smbclient -U zhang3 //192.168.109.237/Public
Enter zhang3's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-169.el6_5]
smb: \>help

挂载
[root@smb ~]  mount -t cifs //192.168.109.237/Pulic /mnt/smb/Public -o username=zhang3,password=<password>




(责任编辑:IT)
------分隔线----------------------------