美文网首页
centos 安装samba

centos 安装samba

作者: 带马界的神秘人 | 来源:发表于2017-08-04 19:20 被阅读0次

    关闭SELinux

    # 临时关闭
    setenforce 0
    
    # 修改配置文件
    
    vim /etc/selinux/config
    
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=enforcing
    # SELINUXTYPE= can take one of three two values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected. 
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted
    
    

    安装samba

    yum install samba samba-client samba-swat
    

    安装成功之后查看服务状态

    service smb status
    
    # 以下是状态 未启动 证明安装成功
      smb.service - Samba SMB Daemon
       Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
       Active: inactive (dead)
    

    添加开机启动

    chkconfig  --level 35 smb on
    

    取消开机启动

    chkconfig  --level 35 smb off
    

    配置

    添加 share 并指定目录 /home/share

    vim /etc/samba/smb.conf
    
    # 修改为如下内容
    # See smb.conf.example for a more detailed config file or
    # read the smb.conf manpage.
    # Run 'testparm' to verify the config is correct after
    # you modified it.
    
    [global]
            workgroup = SAMBA
            security = user
    
    
            passdb backend = tdbsam
    
           # map to guest = Bad Password
    
            #guest account = guest
    
    [share]
           comment = share folder
           path = /home/share
           create mask = 0664
           directory mask = 0775
           browseable = yes
           writable = yes
           public = yes
    
    

    运行 testparm 检查配置是否正确

    testparm
    

    添加用户

    运行下面命令 添加root用户并设置密码

    smbpasswd -a root
    

    启动并查看状态

    service smb start
    service smb status
    

    客户端安装并映射

    1. 安装映射工具

     yum install cifs-utils
    

    2. mount映射

    mount -t cifs //serviceip//share /home/share -o username=root,password=123123
    

    3. 取消映射

    umount /home/share
    

    4. 添加开机自动映射

    vim /etc/fstab
    
    #追加
    //serviceip/share    /home/share             cifs    defaults,auto,username=root,password=123123 0 0
    

    相关文章

      网友评论

          本文标题:centos 安装samba

          本文链接:https://www.haomeiwen.com/subject/khsblxtx.html