SMB(Samba簡稱)是一組通信協定,它運作于Unix.OS/2和MS-Windows系統之間,以實作檔案共享和列印機共享服務,WIDOWS客戶機通過NetBIOS對話傳送伺服器消息來使用伺服器的檔案和列印機資源.NETBIOS定義了運作于DOS上的網絡界面,但沒有規定實際用來傳送資料的網絡協定.Samba使用NetBIOS over TCP/IP,這種方式有很多優點.
SMB使LINUX計算機在網絡鄰居中看起來如同一台WINDOWS計算機.WINDOWS計算機的使用者可以登入到LINUX計算機中,從LINUX檔案系統中複制檔案等.
一、啟動Samba
可以圖形化啟動,也可以指令行啟動方式。
先檢查下安裝沒,這裡可以看到安裝好了。
然後指令方式啟動,成功。
二、smb.conf檔案說明
下面看檔案的說明
[global] //設定整體環境
workgroup = MYGROUP //設定工作組名稱,該名稱會出現在WINDOWS的網路上的芳鄰和LINUX的網絡伺服器中。
server string = Samba Server // 伺服器名說明
; hosts allow = 192.168.1. 192.168.2. 127. 此選項對于安全性非常重要,它嚴格限制了可通路Samba Server的IP範圍,預設是允許所有的IP通路,如果設定,那麼設定好這後應去掉前面的“;”号
printcap name = /etc/printcap // 設定列印機配置檔案路徑
load printers = yes //是否将列印機共享
; printing = cups //列印機的類型,若使用的列印機是LINUX标準型的,則不需要更改列印機類型,通常标準型的列印機類型包括:bsd,sysv,plp,lprng,aix,hpux,qnx和cups
cups options = raw //
; guest account = pcguest //如果想讓使用者“pcguest:以匿名使用者身份登入,去掉前面的“;”号,并確定在/etc/passwd中有此使用者,這裡的“pcguest“可以根據需要改成使用者自己設定的本地使用者。
log file = /var/log/samba/%m.log // log會在此目錄中為每個登入Samba的使用者建立不同的日志檔案。
max log size = 50 //定義了檔案夾的大小,預設是不對日志檔案做大小限制的
下面是關于安全級别的設定
security = user // 安全級别,提供了4種安全等級:share,user,server,domain
; password server = <NT-Server-Name> //密碼驗證伺服器,當使用者從WINDOWS通過SAMBA使用LINUX時,會自動傳送登入WINDOWS時的使用者名與密碼給SAMBA,然後SAMNBA向PASSWORD SERVER驗證這兩項資訊是否正确,若不正确,則會出現對話框,要求使用者重新輸入。(WINDOWS NT和WINDOWS2000也會如上,WINDOWS98隻會要求輸入密碼,是以建議與LINUX賬号相同的名稱來登入WINSOW98。)而這個密碼伺服器可以是WINDOWS NT SERVER(通常是主域控制器),或是另外一個SAMBA SERVER。是以若SECURITY=SERVER,則需要指定密碼伺服器,若SECURITY=SHARE,則需删除關于密碼伺服器的那一行。
; password level = 8 //密碼級别設定
; username level = 8
; encrypt passwords = yes// 使用者密碼要加密,由于現在WINDOWS98/NT皆使用加密的密碼,是以要有這一項,當然也可以要求使用不加密的密碼。
; smb passwd file = /etc/samba/smbpasswd //獎密碼伺服器設定為SAMBA SERVER時,需要用此行來指定要驗證的密碼檔案,若設定為WIDOWS NT SERVER,則不需要此行,這裡最重要的是密碼檔案設定的路徑。
; unix password sync = Yes
; passwd program = /usr/bin/passwd %u //接下來的兩行設定用來容許WINDOWS密碼改變後更新LINUX系統的密碼,确定“encrypt passwords“和"smb passwd file“項被啟用
; passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*
; username map = /etc/samba/smbusers//在此檔案中設定對應的使用者名稱
; include = /etc/samba/smb.conf.%m //在此行允許使用者自己定義每台計算機的基本配置檔案,%m代表NETBIOS正在連接配接的計算機名稱。
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 //設定伺服器和客戶之間會話的socket選項,此項設定将優化傳輸速度。
; interfaces = 192.168.12.2/24 192.168.13.2/24 //如果有多網絡界面必須在此列出
; remote browse sync = 192.168.3.25 192.168.5.255 // 本行和下一行是遠端浏覽設定
; remote announce = 192.168.1.255 192.168.2.44
; local master = no
; os level = 33
; domain master = yes
; preferred master = yes
; domain logons = yes
; logon script = %m.bat
; logon script = %U.bat
; name resolve order = wins lmhosts bcast
; wins support = yes
; wins server = w.x.y.z //WINS用戶端設定
; wins proxy = yes障礙
dns proxy = no //DNS PROXY設定,預設是不為客戶做DNS查詢
; preserve case = no
; short preserve case = no
; default case = lower
; case sensitive = no
#============================ Share Definitions ==============================
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
template shell = /bin/false
winbind use default domain = no
[homes] //使用者通路自己目錄的設定
comment = Home Directories //說明檔案或目錄類型
browseable = no //使用者私人目錄,不需要給别人浏覽
writable = yes //使用者寫入自己目錄的權限
# Un-comment the following and create the netlogon directory for Domain Logons
; [netlogon] //域使用者登入目錄設定
; comment = Network Logon Service
; path = /home/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 user's home directory
;[Profiles] //預設PROFILE設定
; path = /home/profiles
; browseable = no
; guest ok = yes
# 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 //列印機池,使用者必須自行建立目錄
browseable = no //此地存放列印機的臨時檔案
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = 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
; public = yes
; read only = yes
; write list = @staff
# Other examples.
#
# A private printer, usable only by fred. Spool data will be placed in fred's
# home directory. Note that fred must have write access to the spool directory,
# wherever it is.
;[fredsprn]
; comment = Fred's Printer
; valid users = fred
; path = /homes/fred
; printer = freds_printer
; public = no
; printable = yes
# A private directory, usable only by fred. Note that fred requires write
# access to the directory.
;[fredsdir]
; comment = Fred's Service
; path = /usr/somewhere/private
; writable = yes
; printable = no
# 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/pc/%m
; public = no
; writable = yes
# 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 user's 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.
;[public]
; path = /usr/somewhere/else/public
; only guest = yes
# The following two entries demonstrate how to share a directory so that two
# users can place files there that will be owned by the specific users. In this
# setup, the directory should be writable by both users and should have the
# sticky bit set on it to prevent abuse. Obviously this could be extended to
# as many users as required.
;[myshare]
; comment = Mary's and Fred's stuff
; path = /usr/somewhere/shared
; valid users = mary fred
; create mask = 0765
三.配置Samba伺服器
1.配置share級伺服器.
share級在4個等級中是最低的,配置方法也是最簡單.隻需修改/etc/smb.conf檔案如下:
看最後一行,允許IP段通路.
看光标所在處,這裡需要指定一個使用者賬号,yang是伺服器中已經存在的一個賬号.
光标處是share
[tmp]這裡是可以設定要共享的任何目錄.
設定好後要檢查正确性了.
執行testparm指令.測試smb.conf的正确性
有"OK"表示加載正常.
下面按ENTER
上面列出了配置的情況
執行snvclient指令檢視資源共享情況.
最後要重新啟動Samba服務.使配置檔案生效.
下面來看測試.
這是在WINDOWS上,打開網路上的芳鄰.可看到配置時顯示的名稱LINUX.
進去以後看到伺服器.
可看到配置的共享檔案夾TMP
進去後可通路裡面的内容了.可知配置成功.
然後來看用LINUX客戶通路
在LINUX系統中,打開應用程式/網絡伺服器.然後點WINDOWS網絡.
可看到LINUX
可看到剛才第一個畫面的HAIDA,其實是一樣的.
可看到共享檔案夾是一個卷.
進去後同樣可通路其内容了.
本文轉自yangming1052 51CTO部落格,原文連結:http://blog.51cto.com/ming228/109993,如需轉載請自行聯系原作者