2010年11月4日 星期四

Samba 網路芳鄰



1.相關套件:
samba-client-3.0.33-3.28.el5
samba-common-3.0.33-3.28.el5
samba-3.0.33-3.28.el5

2.設定檔: 
#vim  /etc/samba/smb.conf
[global]        //全域設定,這邊的設定是關於整個samba server
       workgroup = MYGROUP
       server string = Samba Server Version %v
       security = user      //預設為user
                  //可設定share,user,server,domain,ads等
       passdb backend = tdbsam
//到下一個[home]前都是[global]相關設定區塊
[home]   //登入後會看到家目錄
 
        comment = Home Directories
        browseable = no 
        writable = yes

[tmp]      //設定分享的目錄
        comment = tmp file    //註解區內容
        path = /tmp     //要分享的目錄
        writable = no   //唯讀,同 read only = yes
        public = yes    //公開讓別人看到
        hosts allow = 140.137.215.89    //這兩行表示拒絕所有連線,
        hosts deny = 0.0.0.0/0                 //僅允許89那台主機使用這個目錄
        valid users = max    //僅user: max可以讀取,群組用@group

#testparm    //用來測試smb.conf有無格式或文字上的錯誤
#/etc/init.d/smb restart

3.測試:
用windows測試:(ip:140.137.215.89)
在執行打\\ip\目錄即可,但如果要測試很多人的帳號密碼
由於windows會記得登入資訊一段時間,可輸入
c:\>net use * /del /y     //清除資訊

用linux測試:(ip:140.137.215.238)
# smbclient -L //140.137.215.238 -U max
Password:
Domain=[A238] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]

        Sharename       Type      Comment
        ---------       ----      -------
        www             Disk      www file
        IPC$            IPC       IPC Service (Samba Server Version 3.0.33-3.28.el5)
        max             Disk      Home Directories
Domain=[A238] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------
        MYGROUP

# smbclient  //140.137.215.238/www -U max
Password:
Domain=[A238] OS=[Unix] Server=[Samba 3.0.33-3.28.el5]
tree connect failed: NT_STATUS_ACCESS_DENIED
//因為有設定僅ip:140.137.215.89可以連線

4.情境實作:
建立一個目錄/opt/boss,只提供帳號zoe使用,資源名稱為storage
ans:
#mkdir /opt/boss
#chown zoe. /opt/boss
#chmod 700  /opt/boss
#vim /etc/samba/smb.conf    //加入
[storage]
        comment = boss storage
        path = /opt/boss
        writable = yes
        public = no
        valid users = zoe    //僅允許zoe使用
        browseable = no    //不會list
#/etc/init.d/smb restart

建立一資源名稱為webproject,供webuser組的所有帳號存取,目錄為/opt/project
ans:
# mkdir /opt/project
# chown :webuser /opt/project
# chmod 770 /opt/project
# vim /etc/samba/smb.conf
[webproject]
        comment = webproject storage
        path = /opt/project
        writable = yes
        public = no
        valid user = @webuser    //表群組
        browseable = no



沒有留言:

張貼留言