2011年7月12日 星期二

Samba 開啟分享 筆記

不知道是從哪邊抓到了 蠻詳細的 保存下來
[Samba基本設定] -test on ubuntu 10.10 (OK)

1.目的
Linux Windows 的機器能共享資源。
所使用的 protocol SMB

2.所需套件
samba-common , samba 以及 samba-client
(
). service 的名稱為:smb
(
). samba 中,主要的 daemon smbd / nmbd ,各肩負不同的責任:
a. smbd
File and Printer Sharing
b. nmbd
Resource Browsing / WINS Server
相關紀錄檔(Log)檔在 /var/log/samba 下。

3.samba 的設定檔/etc/samba/smb.conf
其中以 # ; 為首的資料行被視為註解。

4.預設的設定檔,內有三段:
[global]
workgroup = __________ # Workgroup / Domain Name
server string = _________ #
說明文字
log file = /var/log/samba/%m.log # %m --> The NetBIOS Name of client host
security = user # Or Anonymous
encrypt password = yes
smb password file = /etc/samba/smbpasswd
netbios name = ________ #
若無指定,預設為 hostname

[homes]
comment = home Directories
browseable = no
writable = yes
valid users = %S # %S --> User
create mode = 0664
directory mode = 0775

[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no # guest ok = yes
等同 public = yes
writable = no
printable = yes #
印表機特定選項

5.檢測 smb.conf
 # testparm

6.啟動 samba
# service smb [ status | start | stop | restart ]

[On ubuntu 10.10]

# service smbd [ status | start | stop | restart ]

7.查看特定主機分享出的資源:
# smbclient -L
主機之NetBIOS名稱

8.[nmblookup]
a.
要查詢在目前的區域網路上是否有哪台主機之 NetBIOS name 為某個字
時,可以使用 nmblookup ,如 # nmblookup NetBIOSName
b.
也可用來像某台 WINS server 查詢:
# nmblookup -U wins_server -R NetBIOSName

9.要讓使用者以 john 的身分來使用 samba server 上的資源時,步驟如下:
(
請留意 encrypt password = smb passwd file =)
a.
samba server 上建立帳號
b.
利用 smbpasswd -a john 設定 samba 的密碼
c.
利用 smbclient //host//homes -U john 測試

10.使用某 windows 網路上某台機器所分享出來的資源:
a. smbclient
資源名稱 -U 使用者名稱
# smbclient //hostname/test -U username
b.
windows 上的一個資源掛載(mount)過來
mount
# mount -t smbfs -o passwd=xxx //host/docs /mnt/samba
smbmount

11.請嘗試建立兩個 share
a. myshare
:讓所有人均可讀取。
b. rhce
:只有屬於 rhce 群組的使用者才可以存取。
[myshare]
path = /tmp/test
browseable = yes
public = yes
writeable = yes
[rhce]
path = /tmp/rhce
browseable = no
public = no
valid users = john , mary , @rhce
writeable = yes

12.利用 swat 來設定 samba

13.smbstatus 可用來顯示目前有多少客戶端正在使用本機所提供的 samba 服務


沒有留言:

張貼留言