zoukankan      html  css  js  c++  java
  • SUSE linux 安装配置samba

      对于linux与windows共享,可以用Samba软件实现,Samba是一套免费的开源软件,可以在linux或其他类unix操作系统上实现windows域控制器,文件服务,打印服务等。

      Samba实现了windows系统所使用的核心网络协议:SMB(Server Message Block)。

      Samba可以提供如下功能:

      活动目录服务(Active Directory Server, ADS)

      主域控制器(Primary Domain Controller, PDC)

      共享目录

      共享打印机

      Samba是一个高性能的服务软件,只需要更低的硬件就可以实现windows server相同的性能。

      1.  安装samba

          检查是否已安装samba:linux:/ # rpm -q samba

          如果没有安装显示:package samba is not installed

       如果已安装显示为:samba-3.0.4-1.22 (或其他版本)

      插入CD3,进入linux:/ # cd /media/cdrom/suse/i586,找到需要安装的samba

         

      上图中带黄色框的为主要安装文件,使用命令:linux:/ # rpm -ivh samba-3.0.4-1.22.i586.rpm 进行安装samba。

      2.  配置samba

      2.1 建立共享文件夹

      安装完成后,用上述命令查看是否安装,进入home文件夹下建立一个共享文件夹:share。

      2.2 在yast里面设置server服务器

      打开yast设置进入网络服务,network services->samba server,选择share->add,共享名为:share,description:server,share       path:/home/share

         

        

      2.3 创建用户并加入samba用户组

      linux:/ # useradd -m smb   //添加系统用户

      linux:/ # passwd smb        //输入用户密码 

      密码输入完成后,把smb用户加入到samba用户组中,linux:/ # smbpasswd -a smb //将刚才建立的用户加入samba用户组,并输入访问密码。

      密码输入完成后,对新建的共享文件夹目录share赋予smb用户的权限,linux:/ # chown smb /home/share,linux:/ # chmod 777 /home/share

      2.4 配置smb.conf  

      linux:/ # vi /etc/samba/smb.conf

      修改【global】下的security=user,说明:设置用户访问samba server的验证方式,一共有四种验证方式。

      a. share:用户访问samba server不需要提供用户名和密码,安全性较低。

      b. user:samba server共享目录只能被授权的用户访问,由samba server负责检查账号和密码的正确性。账号和密码要在samba server中建立。

      c. server:依靠其他windows NT/2000 或samba server来验证用户的账号和密码,是一种代理验证。此种安全模式下,系统管理员可以把所有的windows用     户和口令集中到一个NT系统上,使用windows NT进行samba认证,远程服务器可以自动认证全部用户和口令,如果认证失败,samba将使用用户级安全模式作为替代的方式。

      d. domain:域安全级别,使用主域控制器(PDC)来完成认证。

         在2.2步之后,smb.conf文件下面自动添加了【share】段名。

      [share]

      .........

      Writable = Yes

      Browsable = Yes

      Valid users =smb //由于security 为user则需要写上允许的用户名

      Guest ok = on    //打开guest用户

      修改完成后保存文件。

      2.5 重启samba服务器

      linux:/ # /etc/rc.d/smb restart

      3.  windows访问samba服务器

      运行里输入linux IP,输入用户名和密码。

      若是打开了防火墙需要把smb添加到trust 列表中。

      可以通过setup命令进入配置

      可以直接通过iptable来配置访问(这个更安全)

      若是SElinux设置为enforcing

      则设置如下:

      //以下文字位于/etc/samba/smb.conf

      # SELINUX NOTES:
      #
      # If you want to use the useradd/groupadd family of binaries please run:
      # setsebool -P samba_domain_controller on
      #
      # If you want to share home directories via samba please run:
      # setsebool -P samba_enable_home_dirs on    //设置SElinux 策略允许用户访问自己的主目录
      ##//为设置为共享的文件夹设置SELinux安全上下文(context)
      # If you create a new directory you want to share you should mark it as
      # "samba-share_t" so that selinux will let you write into it.
      # Make sure not to do that on system directories as they may already have
      # been marked with othe SELinux labels.
      #
      # Use ls -ldZ /path to see which context a directory has
      # Set labels only on directories you created!
      # To set a label use the following: chcon -t samba_share_t /path
      #
      # If you need to share a system created directory you can use one of the
      # following (read-only/read-write):
      # setsebool -P samba_export_all_ro on
      # or
      # setsebool -P samba_export_all_rw on
      #
      # If you want to run scripts (preexec/root prexec/print command/...) please
      # put them into the /var/lib/samba/scripts directory so that smbd will be
      # allowed to run them.
      # Make sure you COPY them and not MOVE them so that the right SELinux context
      # is applied, to check all is ok use restorecon -R -v /var/lib/samba/scripts

      通过以上设置就可以在开启防火墙、SElinux的情况下正常访问基于REHL的samba服务器

      

  • 相关阅读:
    小程序网络请求封装(三)
    上传图片
    struts2导出excel
    金额超过一定位数显示异常问题
    限制日期控件 最大可选值为当前日期
    substr函数小结
    票号自动生成(按照一定的规则)
    Nginx
    Cron表达式以及定时任务配置
    HTML Input 表单校验之datatype
  • 原文地址:https://www.cnblogs.com/emilyzhang68/p/2556542.html
Copyright © 2011-2022 走看看