部署Samba共享服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了部署Samba共享服务器相关的知识,希望对你有一定的参考价值。

  1. 建立组账户tech、创建员工账号jiashenzhen    chenlongfei
    [[email protected] ~]# groupadd tech

    [[email protected] ~]# useradd -g tech chenlongfei
    [[email protected] ~]# useradd -g tech jiashenzhen
    [[email protected] ~]# useradd common

    2.创建存放共享资源的文件夹/home/samba/data,以及子目录public tech jiashenzhen  chenlongfei
    [[email protected] share]# mkdir public tech jiashenzhen  chenlongfei
    [[email protected] share]# chown root:tech public
    [[email protected] share]# chown root:tech tech
    [[email protected] share]# chown jiashenzhen:root jiashenzhen
    [[email protected] share]# chown chenlongfei:root chenlongfei
    [[email protected] share]# chmod -R 700 jiashenzhen
    [[email protected] share]# chmod -R 700 chenlongfei
    [[email protected] share]# chmod -R 775 public
    [[email protected] 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

    [[email protected] share]# pdbedit -L(验证账户)
    jiashenzhen:501:
    root:0:root
    chenlongfei:502:
    common:503:



    4.修改smb.conf文件,添加共享设置,并启动smb服务
    [[email protected] 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



    子配置文件
    [[email protected] 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





    [[email protected] 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

以上是关于部署Samba共享服务器的主要内容,如果未能解决你的问题,请参考以下文章

Linux中samba共享服务的部署及安全优化详解

9.11SAMBA部署共享服务

centos之samba共享服务

部署Samba共享服务器

Linux下安装部署Samba共享盘的操作手册

samba部署和优化