samba搭建文件共享服务器(centOS 7)

1.安装并启动Samba

  yum -y install samba

  systemctl start smb.service

  // 设置开机启动

  systemctl enable smb.service

2.关闭安全防护

  // 关闭selinux:

  vi /etc/sysconfig/selinux

    SELINUX=enforcing 改为 SELINUX=disabled

  // 关闭防火墙

  systemctl disable firewalld.service

  //重启生效

  shutdown -r now

3.配置文件共享

  // 创建共享目录

  mkdir /home/share

  // 创建用户组和用户  

  groupadd samba

  useradd -g shamba share

  passwd share  // password:share

  // 添加samba文件共享用户

  smbpasswd -a share  //password:share

  // 修改samba配置

  vi /etc/samba/smb.conf

    [global]

      workgroup = samba
      security = user
      map to guest = Bad User
      log file = /var/log/samba/log.%m

    [share]
      comment = share
      valid users = @samba
      read only = yes
      path = /home/share
      hosts allow = 192.168.

  // 重启samba服务

  testparm

  systemctl restart smb.service

4.客户端进行文件挂载

  mkdir /home/share

  mount -t cifs //(ip)/share /home/share -o "username=share,password=share"

猜你喜欢

转载自www.cnblogs.com/-StarrySky-/p/11892434.html