• Samba服务


    1.安装samb服务端和客户端

    yum install samba samba-client samba-swat

    samba-swat  基于https协议的samba服务器web配置界面

    2.启动服务

    [root@wls12c ~]$ /etc/init.d/smb start
    启动 SMB 服务:                                            [确定]
    [root@wls12c ~]$ /etc/init.d/nmb start
    启动 NMB 服务:                                            [确定]

    其中nmb服务是让通过主机名代替IP地址来访问局域网里的主机。

    3.设置开机自启动

    chkconfig --level 35 smb on 

    4.编辑配置文件

    cd /etc/samba/
    mv smb.conf smb.conf.org
    egrep -v '^#|^;|^#' smb.conf.org >smb.conf

    看看过滤后的配置文件

    [global]         #全局参数。
        workgroup = MYGROUP     #工作组名称。
        server string = Samba Server Version %v     #服务器介绍信息,参数%v为显示SMB版本号。
        log file = /var/log/samba/log.%m     #定义日志文件存放位置与名称,参数%m为来访的主机名。
        max log size = 50     #定义日志文件最大容量为50Kb。
        security = user     #安全验证的方式,总共有4种。
        #share:来访主机无需验证口令,更加方便,但安全性很差。
        #user:需由SMB服务验证来访主机提供的口令后才可建立访问,更加的安全。
        #server:使用独立的远程主机验证来访主机提供的口令(集中管理帐号)。
        #domain:使用PDC来完成验证
        passdb backend = tdbsam     #定义用户后台的类型,共有3种。
        #smbpasswd:使用SMB服务的smbpasswd命令给系统用户设置SMB密码。
        #tdbsam:创建数据库文件并使用pdbedit建立SMB独立的用户。
        #ldapsam:基于LDAP服务进行帐户验证。
        load printers = yes     #设置是否当Samba服务启动时共享打印机设备。
        cups options = raw     #打印机的选项
    [homes]         #共享参数
        comment = Home Directories     #描述信息
        browseable = no     #指定共享是否在“网上邻居”中可见。
        writable = yes     #定义是否可写入操作,与"read only"相反。
    [printers]         #打印机共享参数
        comment = All Printers     
        path = /var/spool/samba     #共享文件的实际路径(重要)。
        browseable = no     
        guest ok = no     #是否所有人可见,等同于"public"参数。
        writable = no     
        printable = yes     

    案列1:创建一个共享文件目录,无需密码即可访问

    1.编辑配置文件

     vim smb.conf

    [global]
            workgroup = WORKGROUP
            server string = Samba Server Version %v
            netbios name = wls12c             #定义windows中显示出来的计算机名称
            log file = /var/log/samba/log.%m
            # max 50KB per log file, then rotate
            max log size = 50
            security = share
    
    [public]
            comment = Public Stuff      #对共享目录的说明文件,自己可以定义说明信息
            path = /share
            browseable = yes
            public = yes
            writable = yes

    2.创建共享目录

    mkdir /share
    chmod 777 /share

    3.测试配置的smb.conf是否正确

    [root@wls12c samba]$ testparm
    Load smb config files from /etc/samba/smb.conf
    rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
    Processing section "[public]"
    WARNING: The security=share option is deprecated
    Loaded services file OK.
    Server role: ROLE_STANDALONE
    Press enter to see a dump of your service definitions
    
    [global]
        server string = Samba Server Version %v
        security = SHARE
        log file = /var/log/samba/log.%m
        max log size = 50
        client signing = required
        idmap config * : backend = tdb
    
    [public]
        comment = share all
        path = /share
        read only = No
        guest ok = Yes

    4.重启smb服务

    /etc/init.d/smb restart

    在window访问:

    Linux下访问:

    案列2:公司现有多个部门,因工作需要,将UAT部的资料存放在samba服务器的/UAT 目录中集中管理。

    创建共享目录

    mkdir /uat
    chmod 777 /uat

    添加UAT部和用户

    [root@wls12c ~]$ groupadd uat
    [root@wls12c ~]$ useradd -g uat keven
    [root@wls12c ~]$ useradd -g uat tom

    将刚才创建的用户加入samba中

     修改配置文件

    [global]
            workgroup = WORKGROUP
            server string = Samba Server Version %v
            netbios name = wls12c
            log file = /var/log/samba/log.%m
            # max 50KB per log file, then rotate
            max log size = 50
            security = user
            passdb backend = tdbsam
            load printers = yes
            cups options = raw
    
    [share]
    comment = share for users
    path = /uat
    browseable = yes
    public = no
    writable = yes
    valid users = @uat

    访问

    Linux访问共享文件

    访问服务端
    smbclient //192.168.0.90/share -U samba #匿名访问可以省略掉-U


    挂载和卸载服务端共享目录
    mount -t cifs //192.168.0.90/share /mnt -o username=samba,password=samba
    umount //192.168.0.90/share

    参考:http://www.cnblogs.com/mchina/archive/2012/12/18/2816717.html

  • 相关阅读:
    普通网站迁移
    小程序注册流程
    批量抓取微信公众号的文章
    uniapp 开发踩坑记录
    微信扫码支付精简版
    QueryList The received content is empty!
    阿里云视频点播sdk封装 php
    我的大伯
    tp5分页携带原有参数
    爬虫项目:破解极验滑动验证码
  • 原文地址:https://www.cnblogs.com/zydev/p/5854053.html
Copyright © 2020-2023  润新知