如何和Windows系統做網路芳鄰分享,Server端: Debian-4.0/Client端:WindowsXP/Vista
1. $ sudo dpkg -l samba* <=查詢是否安裝了samba套件(包含了Samba Server), 已安裝請跳至步驟3
2. $ sudo apt-get update & sudo apt-get install samba & sudo cp /etc/samba/smb.conf smb.conf.bak (備份原始設定檔)
3. $ sudo vim /etc/samba/smb.conf <=編輯SAMBA設定檔
4. smb.conf在[global]內有幾個比較重要的設定區段
## Browsing/Identification ### <= 基本的網芳設定,字元編碼,效能設定
#### Networking #### <= 設定是否要綁定IP與介面卡
####### Authentication ####### <= 認證設定..這裡很重要
########## Domains ###########
########## Printing ########## <= 設定印表機分享的參數
############ Misc ############
#======================= Share Definitions ======================= <=下面是集中設定要分享的區域
5. ## Browsing/Identification ###內的設定
# Brows locales code display
charset = UTF8 <=網芳的字元編碼設定使用UTF8,UTF8編碼是國際趨勢,微軟在Vista開始支援
dos charset = cp950 <= 如果Client端是2000/XP/2003,是使用繁體中文為主,則設定cp950
unix charset = UTF8 <= UNIX系統也支援UTF8
netbios name = xxxxx <= xxxx填入你的電腦名稱,此名稱是網芳識別用
workgroup = xxxx <= xxxx工作群組名稱,要在同一個工作群組才能互相看到
server string = xxxx <= server string is the equivalent of the NT Description field
wins support = no <= 預設為註解, WINS Support - Tells the NMBD component of Samba to enable its WINS Server
wins server = w.x.y.z <=預設為註解, Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
dns proxy = no <= This will prevent nmbd to search for NetBIOS names through DNS,如果DNS可用且支援,可設定成Yes
name resolve order = lmhosts host wins bcast <=預設為註解,使用何種方法來反解Host name成IP address
6. ####### Authentication #######內設定
security= xxx <=xxx為驗證方式,share->不需使用者帳號密碼就可進入網芳,是用guest登入/user->需要使用者帳號/密碼,如果使用Linux內的帳號密碼只能使用明碼方式傳輸,SMB建立的帳號密碼可以被加密/ads -> 跟Window AD網域分享有關,筆者下一篇會說明
encrypt passwords = true <=密碼加密
passdb backend = tdbsam:/xxx/xxx/xxx.tdb <= xxx密碼資料庫存放路徑與密碼資料庫名稱
obey pam restrictions = yes
guest account = guest <= security如果設定成share一定要將註解拿掉";或#"
invalid users = root <= 禁止root
unix password sync = yes <=如要用Linux內系統的帳號密碼,此選項要設定成yes,Default is yes
pam password change = no <= Default is no
7. ############ Misc ############內設定
socket options = TCP_NODELAY <=前面加上 ; 或 #將其註解掉,此選項跟SAMBA效能有關,筆者之後統一設定
8. 下面跟SAMBA的 performance有關
# A deadtime of zero indicates that no auto-disconnection should be performed.
deadtime = 15
# Set block size - default is 1024
block size = 4096
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_SUNDBUF=65535 SO_RCVBUF=65535
# Set Max connections number at the same time.
max connections = 10
# Set Max SAMBA processes limits number
max smbd processes = 500
#hostname lookups are currently used is when checking the hosts deny and hosts allow.
hostname lookups = yes
# This parameter determines whether or not smbd(8) supports the new 64k streaming read and write varient SMB requests introduced with Windows 2000
large readwrite = yes
9. 共享資料夾設定 #========= Share Definitions =============,Linux沒有要當分享Server底下可以不用設定
以下使用 ; 或 #將其註解掉,小弟遇到如果沒註解掉,有時候Windows端連到SAMBA server會看到重複的兩個使用者目錄
;[homes]
; comment = Home Directories
; browseable = no
[xxx] <=分享名稱,在網芳上看到的是這個決定
comment = xxx <=類似註解,說明這個分享的資訊
path = /xxx/xxx <= 在SAMBA server端要分享的資料夾路徑
writable = yes <= 允許可以寫入, no是不允許,但此資料夾的權限也要支援使用者可寫入才有作用
guest ok = yes <= 當Security = share,是用guest的方式連入,所以要設定yes才可以,不允許guest就是定成no
browseable = yes <= 允許瀏覽, no是不允許
public = yes <=允許瀏覽, no是不允許,與上者作用似乎一樣,可自行拿掉一個試試看
valid users = @users, xxx <=xxx允許哪些使用者可以進入這個分享資料夾,@users 這個設定項目,加上 @ 之後的名稱代表著群組之意,意思是說,在 Linux 主機上面可使用 Samba 的帳號中,只要該帳號支援 users 這個群組, 那麼理論上他就能夠進入此目錄進行存取的權限。不過能否順利的存取檔案還與 Linux 最底層的檔案權限有關。
create mask = 0770 <=跟權限有關
directory mask = 0770 <= 跟權限有關
10. 設定SAMBA的使用者帳號與密碼
smbpasswd -a xxxx <= 新增一個使用者xxxx
New SMB password: <=在這裡輸入密碼!此密碼不需要和登入Linux系統的密碼相同
Retype new SMB password: <=再輸入一次
Added user xxxx <=新增一個使用者xxx成功
11. $ sudo /etc/init.d/./samba restart <= 重新啟動SAMBA server
12. 使用Windows的網路芳鄰,看看是否能否看的到分享,並能否連入
留言列表