Centos配置Samba

·  阅读 129

Centos配置Samba

简介

主要解决Windows、Linux、MacOS之间文件共享的问题。

安装

前置检查

  1. 临时关闭selinux
sudo setenforce 0
复制代码
  1. 关闭防火墙:
systemctl status firewalld.service  //查看防火墙状态
systemctl stop firewalld.service  //关闭防火墙
复制代码

执行安装命令

  1. 执行yum list命令查看安装包
yum list |grep samba
复制代码
  1. 执行安装命令
sudo yum install samba
复制代码
  1. 启动smb服务
systemctl enable smb  开机启动
systemctl start smb 启动
systemctl status smb  查看状态
systemctl stop smb 关闭
复制代码

配置

以上完成smb服务的安装,要想真正使用,需要配置smb。smb的配置文件在/etc/samba/smb.conf

  1. vim打开配置文件
[global]   
        workgroup = SAMBA
        security = user
        # 修改鉴权方式为smbpasswd
        passdb backend = smbpasswd

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

[homes]
        comment = Home Directories
        # smbgrp为smbgroup
        valid users = @smbgrp
        # 允许浏览
        browseable = Yes
        # 可写
        writable =  Yes
        path = /home/xxxx/

[printers]
        comment = All Printers
        path = /var/tmp
        printable = Yes
        create mask = 0600
        browseable = No

[print$]
        comment = Printer Drivers
        path = /var/lib/samba/drivers
        write list = @printadmin root
        force group = @printadmin
        create mask = 0664
        directory mask = 0775
复制代码

保存配置。 2. 执行如下命令添加smb组及用户

groupadd smbgrp  
useradd hujun -G smbgrp
smbpasswd -a hujun
复制代码
  1. 重启smb
systemctl restart smb
复制代码
  1. 测试smb配置
testparm
输出如下所示:
[global]
        passdb backend = smbpasswd
        printcap name = cups
        security = USER
        workgroup = SAMBA
        idmap config * : backend = tdb
        cups options = raw


[homes]
        comment = Home Directories
        path = /home/hujun/
        read only = No
        valid users = @smbgrp


[printers]
        browseable = No
        comment = All Printers
        create mask = 0600
        path = /var/tmp
        printable = Yes


[print$]
        comment = Printer Drivers
        create mask = 0664
        directory mask = 0775
        force group = @printadmin
        path = /var/lib/samba/drivers
        write list = @printadmin root
复制代码
分类:
阅读
标签:
收藏成功!
已添加到「」, 点击更改