通过SAMBA实现文件共享

步骤:

  1. 安装Samba:
yum -y install samba
  1. 启动Samba:
systemctl start smb
systemctl enable smb
systemctl status smb
  1. 建立共享文件夹:
mkdir /opt/Lichi Library
  1. 建立本地用户和组
useradd user1
groupadd group1
gpasswd -a shenlv share #用户加入该组
  1. 本地用户转变为Samba用户
smbpasswd -a liuyan #转变用户设置密码
  1. 配置Samba文件
vim /etc/samba/smb.conf
[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

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

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

[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

[Lichi]
        comment = Manager Documentroot
        path = /opt/Lichi
        valid users = @share
        writable = yes
  1. 开放防火墙端口
firewall-cmd --zone=public --add-port=139/tcp --permanent
firewall-cmd --zone=public --add-port=445/tcp --permanent
firewall-cmd --zone=public --add-port=137/udp --permanent
firewall-cmd --zone=public --add-port=138/udp --permanent
 
firewall-cmd --reload
systemctl restart firewalld.service

你可能感兴趣的:(通过SAMBA实现文件共享)