CentOS 5.2(Linux)上設定SAMBA Serevr

LINEで送る
[`evernote` not found]

samba是LINUX為了要與WINDOWS可以再NETWORK(網路的芳鄰)共享檔案的服務
參考了鳥哥的文章
先確定

  1. samba
  2. samba-common
  3. samba-client

三個套件都已經裝了
之後因為我是剛裝完就先裝SAMBA
所以原本應該先設定的/etc/sysconfig/i18n就現在一起設定:

1
2
3
4
LANG="zh_TW.UTF-8"
SUPPORTED="zh_HK.UTF-8:zh_HK
zh_SG:zh:zh_TW.UTF-8:zh_TW:z
SYSFONT="latarcyrheb-sun16"

再來是主要的設定檔/etc/samba/smb.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
[global]
        workgroup = workgroup
        netbios name = justC5
        server string = Just samba server
        unix charset = utf8
        display charset = utf8
        dos charset = cp950
        log file = /var/log/samba/%m.log
        max log size = 50
        socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
        dns proxy = no
        template shell = /bin/false
        winbind use default domain = no
 
        security = user
        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
 
        name resolve order = lmhosts bcast host
 
[homes]
        comment = Home directories
        browseable = no
        writeable = yes
        valid users = %S
        create mask = 0664
        directory mask = 0775
[share]
        comment = the user groups work directory
        path = /share
        guest ok = yes
        writeable = yes
[temp]
        comment = Temporary file space
        path = /tmp
        writeable = yes
        guest ok = yes


接下來用smbpasswd -a justfly
打一個原本就存在的USER再新增到SAMBA的使用者中
用testparm測一下:

Load smb config files from /etc/samba/smb.conf
Processing section “[homes]”
Processing section “[share]”
Processing section “[temp]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

是降子就沒問題啦(按下去是跟smb.conf相同的內容)
都OK後就可以 /etc/init.d/smb start來啟動samba服務了測試的話用:
smbclient -L //127.0.0.1來冊訪客的分享

nonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28-1.el5_2.1]

Sharename Type Comment
——— —- ——-
share Disk the user groups work directory
temp Disk Temporary file space
IPC$ IPC IPC Service (Just samba server)
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28-1.el5_2.1]

Server Comment
——— ——-
JUSTC5 Just samba server

Workgroup Master
——— ——-
WORKGROUP JUSTC5

smbclient -L //127.0.0.1 -U justfly 來測試使用者justfly的分享

Domain=[JUSTC5] OS=[Unix] Server=[Samba 3.0.28-1.el5_2.1]

Sharename Type Comment
——— —- ——-
share Disk the user groups work directory
temp Disk Temporary file space
IPC$ IPC IPC Service (Just samba server)
justfly Disk Home directories
Domain=[JUSTC5] OS=[Unix] Server=[Samba 3.0.28-1.el5_2.1]

Server Comment
——— ——-

Workgroup Master
——— ——-
WORKGROUP JUSTC5

可以看到匿名者多了一行Anonymous login successful
使用者多了一個家目錄的分享 -> justfly Disk Home directories
但我的訊息跟鳥哥和其他人網路上不太相同的是少了一行:

ADMIN$ IPC IPC Service (This is samba server)

所以我一度懷疑是因為沒這個東東才沒辦法使用網芳連進來
在家用VM架的centOS是讓我的VISTA一直出現連線拒絕的錯誤訊息
在公司的實體SERVER則是在XP上一直要我輸入帳號密碼
後來才發現是我的SElinux沒有把samba的通道打開
( netstat -tlunp 還是看的到137,138port都開了 )
所以用setup進去把SElinux的samba打開就可以了@@
挖哩勒 搞了我快兩天才發現….一個這麼簡單的東西我就在那邊繞圈圈出不來….T T
最後一個我覺得怪的是
鳥哥的文件說samba-client會包含一個smbmount的指令
可是我卻一直打不出來 …
不過…算了啦….現在還沒有要用linux當作samba-client…^^”