SUSE linux 安裝配置samba

來源:互聯網
上載者:User

  對於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伺服器

 

  

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.