1. 程式人生 > >Linux Samba服務主配檔案smb.conf中文詳解

Linux Samba服務主配檔案smb.conf中文詳解

從網上找到描述比較詳細的smb.conf中文解釋:

  • 服務名:smb
  • 配置目錄:/etc/sabma/
  • 主配置檔案:/etc/sabma/smb.conf
#============================== Global Settings =============================

[global]
samba伺服器的全域性設定,對整個伺服器有效。

workgroup
語法:workgtoup = <工作組群>;
預設:workgroup = MYGROUP
說明:設定 Samba Server 的工作組
例:workgroup = workgroup 和WIN2000S設為一個組,可在網路上的芳鄰可中看到共享。

server string
語法:server string = <說明>; 預設:sarver string = Samba Server 說明:設定 Samba Server 的註釋 其他:支援變數 t%-訪問時間 I%-客戶端IP m%-客戶端主機名 M%-客戶端域名 S%-客戶端使用者名稱 例:server string = this is a Samba Server 設定出現在Windows網路上的芳鄰的 Samba Server 註釋為 this is a Samba Server hosts allow 語法:hosts aoolw = <IP地址>; ... 預設:; host allow = 192.168.1. 192.168.2. 127. 說明:限制允許連線到 Samba Server 的機器,多個引數以空格隔開。表示方法可以為完整的IP地址,如 192.168.0.1 網段,如 192.168.0. 例:hosts allow = 192.168.1. 192.168.0.1 表示允許 192.168.1 網段的機器網址為 192.168.0.1 的機器連線到自己的 samba server printcap name
語法:printcap name = <印表機配置檔案>; 預設:printcap name = /etc/printcap 說明:設定 samba srever 印表機的配置檔案 例:printcap name = /etc/printcap 設定 samba srever 參考 /etc/printcap 檔的印表機設定。 load printers 語法:load printers = <yes/no>; 預設:load printers = yes 說明:是否在開啟 samba server 時即共享印表機。 printing 語法:printing = <印表機型別>; 預設:printing = lprng 說明:設定 samba server 印表機所使用的型別,為目前所支援的型別。 guest account
語法:guert account = <帳戶名稱>; 預設:guert account = pcguest 說明:設定訪問 samba server 的來賓帳戶(即訪問時不用輸入使用者名稱和密碼的帳戶),若設為pcguest的話則為預設為"nobody"使用者。 例:guert account = andy 設定設定訪問 samba server 的來賓帳戶以andy使用者登陸,則此登陸帳戶享有andy使用者的所有許可權。 log file 語法:log file = <日誌檔案>; 預設:log file = /var/log/samba/%m.log 說明:設定 samba server 日誌檔案的儲存位置和檔名(%m代表客戶端主機名) max log size 語法:max log size = <??KB>; 預設:max log size = 0 說明:設定日子檔案的最大容量,單位KB 這裡的預設值0代表不做限制。 security 語法:security = <等級>; 預設:security = user 說明:設定訪問 samba server 的安全級別共有四種: share---不需要提供使用者名稱和密碼。 user----需要提供使用者名稱和密碼,而且身份驗證由 samba server 負責。 server--需要提供使用者名稱和密碼,可指定其他機器(winNT/2000/XP)或另一臺 samba server作身份驗證。 domain--需要提供使用者名稱和密碼,指定winNT/2000/XP域伺服器作身份驗證。 password server 語法:password server = <IP地址/主機名>; 預設:password server = <NT-Server-Name>; 說明:指定某臺伺服器(包括windows 和 linux)的密碼,作為使用者登入時驗證的密碼。 其他:此項需配合 security = server時,才可設定本引數。 password level 語法:password level = <位數>; username level = <位數>; 預設:password level = 8 username level username level = 8 說明:設定使用者名稱和密碼的位數,預設為8位字元。 encrypt passwords 語法:encrypt passwords = <yes/no>; 預設:encrypt passwords = yse 說明:設定是否對samba的密碼加密。 smb passwd file 語法:smb passwd file = <密碼檔案>; 預設:smb passwd file = /etc/samba/smbpasswd 說明:設定samba的密碼檔案。 local master 語法:local master = <yes/no>; 預設:local master = no 說明:設定 samba server 是否要擔當LMB角色(LMB負責收集本地網路的Browse List資源),通常無特殊原因設為no os level 語法:os level = <數字>; 預設:os level = 33 說明:設定 samba server的os level. os level從 0 到 255 . winNT的os level為33, win95/98的os level 是 1 .若要拿samba server 當LMB或DMB則它的os level至少要大於NT的33以上。 domain master 語法:domain master = <yes/no>; 預設:domain master = yes 說明:設定 samba server 是否要擔當DMB角色(DMB會負責收集其他子網的Browse List資源),通常無特殊原因設為no preferred master 語法:preferred master = <yes/no>; 預設:preferred master = yes 說明:設定 samba server 是否要擔當PDC角色(PDC會負責追蹤網路帳戶進行的一切變更),通常無特殊原因設為no,(同一網段內不可有兩個PDC,他們會每5分鐘搶主控權一次) wins support 語法:wins support = <yes/no>; 預設:wins support = yes 說明:設定samba server 是否想網路提供WINS服務,通常無特殊原因設為no。除非所處網路上沒有主機提供WINS服務且需要此臺samba server提供WINS服務是才設yes,其他 wins support 和 wins server 只能選擇一個 wins server 語法:wins server = <IP地址>; 預設:wins server = w.x.y.z 說明:設定samba server 是否要使用別臺主機提供的WINS服務,通常無特殊原因設為no。除非所處網路上有一臺主機提供WINS服務才要設yes,其他 wins support 和 wins server 例:wins server = 192.168.0.1 表示samba server要使用192.168.0.1提供的WINS服務 #============================== Share Definitions ============================= [homes] comment = Home Directories browseable = no writable = yes valid users = %S 使用者本身的"家"目錄,當使用者以samba使用者身份登入samba server 後,samba server 底下會看到自己的家目錄,目錄名稱是使用者自己的帳號。 [printers] comment = All Printers path = /var/spool/samba browseable = no guest ok = no writable = no printable = yes 設定了samba伺服器中列印共享資源的屬性,samba伺服器除了可以提供檔案共享,還可以提供列印共享。 [分享的資源名稱] <指令1>; = (引數) <指令2>; = (引數) 要提供分享資源時,須先把欲分享的資源以 [ ] 符號括住,底下通常會帶指令和引數來表示此資源的設定和存取許可權等,詳情如下: comment---------註釋說明 path------------分享資源的完整路徑名稱,除了路徑要正確外,目錄的許可權也要設對 browseable------是yes/否no在瀏覽資源中顯示共享目錄,若為否則必須指定共享路徑才能存取 printable-------是yes/否no允許列印 hide dot ftles--是yes/否no隱藏隱藏檔案 public----------是yes/否no公開共享,若為否則進行身份驗證(只有當security = share 時此項才起作用) guest ok--------是yes/否no公開共享,若為否則進行身份驗證(只有當security = share 時此項才起作用) read only-------是yes/否no以只讀方式共享當與writable發生衝突時也writable為準 writable--------是yes/否no不以只讀方式共享當與read only發生衝突時,無視read only vaild users-----設定只有此名單內的使用者才能訪問共享資源(拒絕優先)(使用者名稱/@組名) invalid users---設定只有此名單內的使用者不能訪問共享資源(拒絕優先)(使用者名稱/@組名) read list-------設定此名單內的成員為只讀(使用者名稱/@組名) write list------若設定為只讀時,則只有此設定的名單內的成員才可作寫入動作(使用者名稱/@組名) create mask-----建立檔案時所給的許可權 directory mask--建立目錄時所給的許可權 force group-----指定存取資源時須以此設定的群組使用者進入才能存取(使用者名稱/@組名) force user------指定存取資源時須以此設定的使用者進入才能存取(使用者名稱/@組名) allow hosts-----設定只有此網段/IP的使用者才能訪問共享資源 allwo hosts = 網段 except IP deny hosts------設定只有此網段/IP的使用者不能訪問共享資源 allow hosts=本網段指定IP指定IP deny hosts=指定IP本網段指定IP

在使用Samba進行建立Window與Linux共享時,要是不能訪問,出現“您可能沒有許可權使用網路資源”,

解決samba和SELINUX <wbr>衝突
那就是SELinux在作怪了

要是想讓共享目錄能訪問,可以使用命令

#setenforce 0

暫時停掉SELinux

使用

#setenforce 1

啟用SELinux

 

有關SELinux 在系統中的作用就不講了,另外一種方法可以不用關閉SELinux.以下命令將允許這個許可權:

setsebool -P samba_enable_home_dirs=1

 

 

 ————————————————————————————————————————————————

若SElinux啟用中,在Windows檔案總管無法連到 Samba 所分享出來的目錄時,

在Linux 中,可執行下列指令:

setsebool -P samba_enable_home_dirs on

 

參考檔案: /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
#

# 分享home目錄
# If you want to share home directories via samba please run:
setsebool -P samba_enable_home_dirs on
#
# 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
#
#--------------
#