天天看點

smb設定參考手冊

/etc/samba/smb.conf

#----------------------------------------------------------------------------------#

# smb設定參考手冊 #

# #

[global]

# workgroup = NT-Domain-Name or Workgroup-Name

#工作組設定本地網絡使用工作組名字(或者是域)否則,Windows客戶就不能從其網絡鄰居中發現這個Samba伺服器。當然,你要是設定成域時,要把 security = domain設定成這樣

workgroup = Sa119

# server string is the equivalent of the NT Description field

#server string是對于本地伺服器的簡單描述,這些資訊将作為這台伺服器的屬性,傳回給#Browser,顯示在Windows客戶中作為對這個伺服器的描述。

server string = Linux Smb

# This option is important for security. It allows you to restrict

# connections to machines which are on your local network. The

# following example restricts access to two C class networks and

# the "loopback" interface. For more examples of the syntax see

# the smb.conf man page

#用于限制可以通路這台samba伺服器的客戶機的IP位址範圍,以提供安全限制。預設情#況下,這行配置被注釋了, 即所有的客戶都可以通路這台計算機,這樣就存在一定的安全問題。

#通常可以這樣hosts allow = 192.168.0. 。整個網絡号為192.168.0的機器都可以通路,其它的都将拒絕連接配接(注意最後的那個".")

hosts allow = 192.168.0.

# if you want to automatically load your printer list rather

# than setting them up individually then youll need this

#這些設定是用于設定samba伺服器的列印機資源,load printer=yes就允許samba伺服器對外共享伺服器的列印機。

#列印機?...........我沒.............

printcap name = /etc/printcap

load printers = yes

# It should not be necessary to spell out the print system type unless

# yours is non-standard. Currently supported print systems include:

# bsd, sysv, plp, lprng, aix, hpux, qnx

#定義列印系統的類型

printing = lprng

# Uncomment this if you want a guest account, you must add this to /etc/passwd

# otherwise the user "nobody" is used

#由于Mircrosoft客戶沒有使用者的概念,是以有時會用沒有使用者和密碼的請求通路伺服器,就需要将這個沒有使用者的請求映射為系統中的某個使用者,Samba伺服器才能安全的通路系統。guest account 就定義這樣的請求在Unix下對應的使用者權限。為了安全的原因,不能讓這個帳戶在系統中有可寫的權限,通常可以增加一個專用帳戶,如pcguest。如果這個設定被注釋的情況下,系統預設使用nobody執行 Windows客戶的請求。建議不要使用nobody使用者,因為系統中的很多程式預設都使用它,是以就會有安全問題。

#通常可以這樣做先在下面的開關設定security = share ,使smb服務工作于共享級别,删除系統中的nobody帳号,打開 guest account = pcguest (既去掉 ";")

#在系統裡添加一個smb組 groupadd -g 300 smb

#添加smb遊客帳号 useradd -u 300 -g 300 -d /dev/null -s /dev/null smbguest 這樣都将用smbguest這個帳号來影射通路請求

#注意一點的是,當你把security = user設定成這樣(smb服務工作于使用者級别)一但驗證失敗,将退回到share級别

guest account = smbguest

# this tells Samba to use a separate log file for each machine

# that connects

#這裡定義samba的日志檔案路徑,%m用于代表從通路的NetBIOS 計算機名,如果使用的使用者級認證,還可以使用%U表示不同的登入使用者。例如從一名字為cainiao的計算機通路samba伺服器的日志,将記錄在 /var/log/samba/cainiao.log檔案中。

# 一些變量說明:

#%S = 目前服務名

#%P = 目前服務的根目錄

#%u = 目前服務的使用者名

#%g = 目前使用者說在的主工作組

#%U = 目前對話的使用者名

#%G = 目前對話的使用者的主工作組

#%H = 目前服務的使用者的Home目錄

#%v = Samba服務的版本号。

#%h = 運作Samba服務機器的主機名

#%m = 客戶機的NETBIOS名稱

#%L = 伺服器的NETBIOS名稱

#%M = 客戶機的主機名

#%N = NIS伺服器名

#%p = NIS服務的Home目錄

#%R = 說采用的協定等級(值可以是CORE, COREPLUS, LANMAN1, LANMAN2,NT1)

#%d = 目前服務程序的ID

#%a = 客戶機的系統

#%I = 客戶機的IP

#%T = 目前日期和時間

log file = /var/log/samba/%I.log

# Put a capping on the size of the log files (in Kb).

#max log size定義每個日志檔案的存儲限制。預設是0,(無限制)

#一定要定義好,防止硬碟被爆掉 ^_^

max log size = 20

# Security mode. Most people will want user level security. See

# security_level.txt for details.

#認證方式,包括簡單的共享級認證和使用者級認證。Unix為多使用者作業系統,預設就使用使用者級認證方式。當使用使用者級認證的時候,Samba伺服器使用Unix作業系統的使用者和密碼(來自/etc/passwd )對使用者進行認證,這是一種獨立的認證方式。而有時候希望所有的伺服器使用同一個認證資料庫進行統一認證,是以就導緻出現了基于域的統一認證模式。在一個域中,使用者隻需要通過域控制器進行認證即可,域中其他SMB伺服器就将認可域控制器的認證。為了使Samba伺服器支援域認證方式,可以有兩種不同的設定方式,一種為真正的域認證,另一種為伺服器認證方式,将Samba伺服器配置為通過伺服器驗證使用者,這需要指定security=server,以及指定password server的名字為NT的域控制器。認證伺服器的方式不能事先域認證方式提供的一些特征,但它的适用範圍并不僅限于域,使用工作組的網絡也能通過統一的認證伺服器來使用統一認證模式。

#一共有4種服務級别,分别是

#share:沒有安全性的級别,任何使用者都可以不要使用者名和密碼通路伺服器上的資源。

#user:samba的預設配置,要求使用者在通路共享資源之前資源必須先提供使用者名和密碼進行驗證。

#server:和user安全級别類似,但使用者名和密碼是遞交到另外一個伺服器去驗證,比如遞交給一台#NT伺服器。如果遞交失敗,就退到user安全級,以此類推。

#domain:這個安全級别要求網絡上存在一台Windows的主域控制器,samba把使用者名和密碼遞交#給它去驗證。

security = share

# Use password server option only with security = server

# The argument list may include:

# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]

# or to auto-locate the domain controller/s

# password server = *

# 當服務級别使用server或者domain時,才需要設定這個

; password server = <NT-Server-Name>

# Password Level allows matching of _n_ characters of the password for

# all combinations of upper and lower case.

#系統在發送使用者密碼的時候,會把密碼轉換成大寫再發送,這樣就和samba的密碼不一緻,這個參數可以設定密碼裡允許的大寫字母個數,這樣samba就根據這個數目對接收到的密碼進行大小寫重組,以重組過的密碼嘗試驗證密碼的正确性。n越大,組合的次數就越多,驗證時間就越長,安全性也會是以變得越低。例如n=2,使用者的密碼是abcd,但發送出去其實是ABCD,samba就會把這個ABCD進行大小寫重組,組合後的結果可以是: Abcd, aBcd, abCd, abcD, abcd, ABcd, AbCd, AbcD,aBCd,aBcD,abCD。是以如果沒有必要,就把n定為是零。這樣的話samba隻嘗試兩次,一個是接收到的密碼,另一個嘗試的是這個密碼都是小寫的情況。 username level = 8 情況類似。

; password level = 8

; username level = 8

# You may wish to use password encryption. Please read

# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.

# Do not enable this option unless you have read those documents

#客戶機和伺服器之間進行認證時,把加密密碼傳輸,這樣保證了安全性。當然你的windows工作站要支援。因為一些老式的windows系統預設是不支援的(win95?好象現在沒幾個人用吧)

encrypt passwords = yes

#定義smb帳号密碼檔案路徑

smb passwd file = /etc/samba/smbpasswd

# The following is needed to keep smbclient from spouting spurious errors

# when Samba is built with support for SSL.

#當起用ssl模式時,這裡定義了ssl證書的位置.

; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt

# The following are needed to allow password changing from Windows to

# update the Linux sytsem password also.

# NOTE: Use these with encrypt passwords and smb passwd file above.

# NOTE2: You do NOT need these to allow workstations to change only

# the encrypted SMB passwords. They allow the Unix password

# to be kept in sync with the SMB password.

#設定能否同步unix,smb密碼.

unix password sync = Yes

passwd program = /usr/bin/passwd %u

passwd chat = *New*password* %n\n *Retype*new*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*

# You can use PAMs password change control flag for Samba. If

# enabled, then PAM will be used for password changes when requested

# by an SMB client instead of the program listed in passwd program.

# It should be possible to enable this without changing your passwd

# chat parameter for most setups.

pam password change = yes

# Unix users can map to different SMB User names

#使用者映射檔案客戶機的使用者是admin或者administrator連接配接時會被當作使用者root看待。你可以打開/etc/samba/smbusers看看裡面有什麼?

; username map = /etc/samba/smbusers

# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting

#針對不同的連接配接而使用不同的smb.conf檔案。這樣可以讓smb伺服器更加強大和靈活,當然咯,在強大靈活的背後,就是會讓設定變的更加複雜,是以我沒有打開這個參數。我怕^_^

; include = /etc/samba/smb.conf.%m

# This parameter will control whether or not Samba should obey PAMs

# account and session management directives. The default behavior is

# to use PAM for clear text authentication only and to ignore any

# account or session management. Note that Samba always ignores PAM

# for authentication in the case of encrypt passwords = yes

obey pam restrictions = yes

# Most people will find that this option gives better performance.

# See speed.txt and the manual pages for details

# 用于配置對TCP的處理方式。不太清楚,不多廢話了。誰知道啊?

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

# Configure Samba to use multiple interfaces

# If you have multiple network interfaces then you must list them

# here. See the man page for details.

#這個是設定把smb服務綁定到具體的網絡接口上。否者smb服務将運作在所有的網絡接口上。

; interfaces = 192.168.12.2/24 192.168.13.2/24

#當通路共享資源時,首先要先擷取網絡中的資源清單,預設情況下browser是由網絡中的每個計算機來維護的。但沒有必要每個計算機都維護整個資源清單,維護網絡中目前資源清單的任務由網絡上的幾個特殊計算機完成的,這些計算機被稱為Browser

# Configure remote browse list synchronisation here

# request announcement to, or browse list sync from:

# a specific host or from / to a whole subnet (see below)

; remote browse sync = 192.168.3.25 192.168.5.255

# Cause this host to announce itself to local subnets here

; remote announce = 192.168.1.255 192.168.2.44

# Browser Control Options:

# set local master to no if you dont want Samba to become a master

# browser on your network. Otherwise the normal election rules apply

# 設定sam伺服器是否能做為網絡中的主browser

; local master = no

# OS Level determines the precedence of this server in master browser

# elections. The default value should be reasonable

# browser優先權的設定

; os level = 33

# Domain Master specifies Samba to be the Domain Master Browser. This

# allows Samba to collate browse lists between subnets. Dont use this

# if you already have a Windows NT domain controller doing this job

#設定smb伺服器能否做為一個域的主browser,如果你的網絡裡已經有pdc(主域控制器),就不能設定這裡。

; domain master = yes

# Preferred Master causes Samba to force a local browser election on startup

# and gives it a slightly higher chance of winning the election

; preferred master = yes

# Enable this if you want Samba to be a domain logon server for

# Windows95 workstations.

#激活smb的域登陸伺服器。

; domain logons = yes

# if you enable domain logons then you may want a per-machine or

# per user logon script

# run a specific logon batch file per workstation (machine)

#如果你采用domain方式登陸,必須設定登陸腳本。

#每個工作站登陸腳本。

; logon script = %m.bat

# run a specific logon batch file per username

#每個使用者的登陸腳本。

; logon script = %U.bat

# Where to store roving profiles (only for Win95 and WinNT)

# %L substitutes for this servers netbios name, %U is username

# You must uncomment the [Profiles] share below

; logon path = \\%L\Profiles\%U

#以下是和wins(網絡命名服務)伺服器有關的一些設定,我不太清楚,知道的朋友,可以幫忙加上去。

# Windows Internet Name Serving Support Section:

# WINS Support - Tells the NMBD component of Samba to enable its WINS Server

; wins support = yes

# WINS Server - Tells the NMBD components of Samba to be a WINS Client

# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both

; wins server = w.x.y.z

# WINS Proxy - Tells Samba to answer name resolution queries on

# behalf of a non WINS capable client, for this to work there must be

# at least one WINS Server on the network. The default is NO.

; wins proxy = yes

# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names

# via DNS nslookups. The built-in default for versions 1.9.17 is yes,

# this has been changed in version 1.9.18 to no.

dns proxy = no

# Case Preservation can be handy - system default is _no_

# NOTE: These can be set on a per share basis

#設定copy檔案時,保持大小寫

; preserve case = no

; short preserve case = no

# Default case is normally upper case for all DOS files

#設定檔案名是否大寫還是小寫,改成小的吧,我喜歡小的,嘿嘿~

default case = lower

# Be very careful with case sensitivity - it can break things!

#設定是否大小寫敏感,還是no或加";"

; case sensitive = no

#先看這些讓人頭大的參數:

#[xxxx] :定義共享資源的名字。

#comment = xxxx :定義共享資源的描述。

#path = /home/share :定義共享資源的實體路徑。

#writeable = yes|no :定義目錄是否可以寫。

#readonly =yes|no :同上!

#valid users = user (@group):設定可以通路該共享資源的使用者或者組。

#invalid users = user (@group) :設定禁止通路該共享資源的使用者或者組。

#read list = user (@group) :設定可以讀取該共享資源的使用者或者組。

#write list = user (@group) :設定可以讀取和寫入該共享資源的使用者或者組。

#admin list = user (@group) :設定可以管理該共享資源的使用者或者組。

#guest ok = yes|no :設定該共享資源是否能被來賓帳号通路。

#public = yes|no : 同上,寫法不同而已。

#hide dot files = yes|no :是否顯示隐藏檔案。即以"."開頭的檔案。

#directory mode 0755 :定義建立目錄的權限。

#create mode 0755:定義建立檔案的權限。

#wide links = yes|no :定義是否能使用連接配接符号。

# browseable =yes|no:網絡浏覽表是否顯示

#max connections = n 最大的連接配接數

#force create mode 0755 強制檔案屬性

#force directory mode 0755 強制目錄屬性

#force user 強制檔案屬主

#share modce = yes|no 是否目前使用者使用

#client code page = 950 中文設定

#大概常用的就這些了。需要注意的一點是權限設定問題,比如:定義了一個名字為:tools的共享資源。路徑為/home/smbhome/,且你已經使用writeable = yes或者write list = user (@group) 來定義了它是可以寫的。但就不能寫,why?請檢查/home/smbhome目錄的權限。也就是說,系統所設定的權限,要高于smb所設定的。

#下面用一個列子來說明如何設定共享。先把下面沒有注釋掉的字段全部注釋掉。預設的設定不安全也不需要。

# 1.建立一個共享share。可以匿名通路,隻能讀。使用者smbuser1可以寫和讀。

# 2.groupadd -g 300 smb /*建立smb組*/

# 3.useradd -u 300 -g 300 -d /dev/null -s /dev/null smbguest /*建立來賓帳号*/

# 4.smbguest 要和你在 guest account = smbguest 字段中定義的一緻。

# 5.useradd -u 301 -g 300 -d /dev/null -s /dev/null smbuser1 /*建立smbuser1帳号*/

# 6.security = user /*把smb服務設定為使用者級别*/

# 7.mkdir /home/smbhome /*建立/home/smbhome目錄*/

# 8.chown smbuser1 /home/smbhome /*設定屬主*/

# 9.chgrp smb /home/smbhome /*設定屬組*/

# 10. chmod 0775 /home/smbhome /*設定權限*/

# 11. smbpasswd -a smbuser1 /*建立smbuser1帳号并設定密碼.如果smbpasswd在你的系統上不工作,用smbadduser試下。*/

[share]

comment = linux share

path = /home/smbhome

guest ok = yes

write list = smbuser1

printable = no

directory mode 0775

create mode 0775

wide links = no

# 一些技巧和提示:

# 推介用vi來修改,因為它可以讓你的眼球感到愉快.

# 修改完成後,需要重新開機動smb服務使你的設定生效,你可以用service smb restart(如果這條指令在你的系統上不工作,你可以嘗試以下的:/etc/rc.d/init.d/samba restart 或者 /etc/rc.d/init.d/smb restart)

# 你可以使用testparm | more 指令來測試你的smb.conf檔案是否有文法錯誤,并給出每個參數的詳悉設定.

# hmomes這個共享比較特殊,一般沒有對這個目錄的設定路徑。當客戶機發出服務請求時,那麼就搜尋密碼檔案/etc/passwd得到使用者的Home目錄。通過Homes段,Samba可以得到使用者的Home目錄并使之共享。

#--------------------------------Share Definitions --------------------------------#

[homes]

comment = Home Directories

browseable = no

writable = yes

valid users = %S

create mode = 0755

directory mode = 0755

# If you want users samba doesnt recognize to be mapped to a guest user

; map to guest = bad user

# Un-comment the following and create the netlogon directory for Domain Logons

; [netlogon]

; comment = Network Logon Service

; path = /usr/local/samba/lib/netlogon

; guest ok = yes

; writable = no

; share modes = no

# Un-comment the following to provide a specific roving profile share

# the default is to use the users home directory

;[Profiles]

; path = /usr/local/samba/profiles

; browseable = no

# NOTE: If you have a BSD-style print system there is no need to

# specifically define each individual printer

;[printers]

; comment = All Printers

; path = /var/spool/samba

# Set public = yes to allow user guest account to print

; guest ok = no

; printable = yes

# This one is useful for people to share files

;[tmp]

; comment = Temporary file space

; path = /tmp

; read only = no

; public = yes

# A publicly accessible directory, but read only, except for people in

# the "staff" group

;[public]

; comment = Public Stuff

; path = /home/samba

; writable = yes

; printable = no

; write list = @staff

# Other examples.

#

# A private printer, usable only by fred. Spool data will be placed in freds

# home directory. Note that fred must have write access to the spool directory,

# wherever it is.

;[fredsprn]

; comment = Freds Printer

; valid users = fred

; path = /home/fred

; printer = freds_printer

; public = no

# A private directory, usable only by fred. Note that fred requires write

# access to the directory.

;[fredsdir]

; comment = Freds Service

; path = /usr/somewhere/private

# a service which has a different directory for each machine that connects

# this allows you to tailor configurations to incoming machines. You could

# also use the %U option to tailor it by user name.

# The %m gets replaced with the machine name that is connecting.

;[pchome]

; comment = PC Directories

; path = /usr/local/pc/%m

# A publicly accessible directory, read/write to all users. Note that all files

# created in the directory by users will be owned by the default user, so

# any user with access can delete any other users files. Obviously this

# directory must be writable by the default user. Another user could of course

# be specified, in which case all files would be owned by that user instead.

; path = /usr/somewhere/else/public

; only guest = yes

繼續閱讀