天天看點

CentOS 6.4下安裝和配置Samba

Samba是linux和Windows檔案共享的正常方案,當然也可以在linux之間共享。

一、安裝Samba

yum -y install samba samba-client      

安裝完後檢查版本

[root@peanuthost samba]# rpm -qa | grep samba
samba-common-3.6.9-151.el6_4.1.i686
samba-winbind-3.6.9-151.el6_4.1.i686
samba-client-3.6.9-151.el6_4.1.i686
samba-winbind-clients-3.6.9-151.el6_4.1.i686
samba-3.6.9-151.el6_4.1.i686      

可以看到Samba的版本是3.6.9,其他有依賴關系的包也安裝上了。

安裝包說明(zz David Camp)

samba-common //主要提供samba伺服器的設定檔案與設定檔案文法檢驗程式testparm

samba-client //用戶端軟體,主要提供linux主機作為用戶端時,所需要的工具指令集

samba //伺服器端軟體,主要提供samba伺服器的守護程式,共享文檔,日志的輪替,開機預設選項

samba-swat //基于https協定的samba伺服器web配置界面 (此處沒有安裝)

Samba伺服器安裝完畢,會生成配置檔案目錄/etc/samba和其它一些samba可執行指令工具,/etc/samba/smb.conf是samba的核心配置檔案,/etc/init.d/smb是samba的啟動/關閉檔案。

二、開啟smb服務,關閉SElinux和Iptables

直接使用service smb start 啟動Samba服務。

# getenforce指令可以檢視SElinux的狀态 ,# setenforce 0可以暫時關閉SElinux,在/etc/selinux/config中把SELINUX= enforcing更改為SELINUX=disable可以永久關閉SELinux

# service iptables status可以檢視Iptables的狀态,# service iptables stop可以暫時關閉,# chkconfig iptables off可以永久關閉防火牆。

最後關閉後的狀态應該是

SElinux:Disabled

Iptables:Firewall is not running

這兩個服務在沒配置時一定要是關閉狀态,不然會通路不到!

檢視samba的服務啟動情況

# service smb status

設定開機自啟動

# chkconfig --level 35 smb on //在3、5級别上自動運作samba服務

三、配置Samba

Samba的主配置檔案為/etc/samba/smb.conf

主配置檔案由兩部分構成

  • Global Settings (55-245行)

  該設定都是與Samba服務整體運作環境有關的選項,它的設定項目是針對所有共享資源的。

  • Share Definitions (246-尾行)

  該設定針對的是共享目錄個别的設定,隻對目前的共享資源起作用。

配置的詳細解釋和案例可以參見《CentOS 6.3下Samba伺服器的安裝與配置》,寫的很詳細。

參照做過一遍,基本都通過了,遇到一個小問題,記錄一下:

使用本地的client去通路時遇到LANMAN錯誤

[root@peanuthost share]# smbclient //localhost/public
WARNING: The security=share option is deprecated
Enter root's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-151.el6_4.1]
Server not using user level security and no password supplied.
Server requested LANMAN password (share-level security) but 'client lanman auth = no' or 'client ntlmv2 auth = yes'
tree connect failed: NT_STATUS_ACCESS_DENIED      
client lanman auth = Yes
lanman auth = Yes      
[root@peanuthost share]# service smb restart
Shutting down SMB services:                                [  OK  ]
Starting SMB services:                                     [  OK  ]
[root@peanuthost share]# smbclient //localhost/public
WARNING: The security=share option is deprecated
Enter root's password:
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.9-151.el6_4.1]
Server not using user level security and no password supplied.
smb: \>      

繼續閱讀