下載下傳完成後tar xvzf samba*.tar.gz
然後執行cd source/;./configure && make && make install && make installbin && make installman
安裝完成以後我們就可以看windows的共享目錄了,我們首先檢視目标我們輸入
[root@localhost /]# smbtree
Password:
WORKGROUP
這裡就可以看到了共享的機器CNBIRD了,
找到了共享了目錄以後我們輸入
[root@localhost /]# nmblookup CNBIRD
querying CNBIRD on 192.168.0.255
192.168.0.1 CNBIRD<00>
192.168.1.1 CNBIRD<00>
192.168.234.1 CNBIRD<00>
[root@localhost /]#
我們就可以得到CNBIRD這台機器的IP位址了,這裡IP很多,主要是安裝了Vmware的原因。
我們下面就來具體的檢視我們目錄中有什麼東西了,
[root@localhost /]# smbclient -L 192.168.0.1 -Uredhat%redhat
Domain=[CNBIRD] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
IPC$ IPC ÈÂ│╠ IPC
hacker Disk
cnbird Disk
session request to 192.168.0.1 failed (Called name not present)
session request to 192 failed (Called name not present)
Server Comment
--------- -------
Workgroup Master
我們用redhat和密碼redhat來進行檢視共享。
下面就是我們需要看共享裡面的内容了,我們輸入
[root@localhost /]# smbclient //192.168.0.1/hacker -U redhat%redhat
smb: />
這個時候我們就入了smb裡面了,我們輸入help來檢視一下具體的指令,
smb: /> help
? altname archive blocksize cancel
case_sensitive cd chmod chown del
dir du exit get hardlink
help history lcd link lowercase
ls mask md mget mkdir
more mput newer open print
printmode prompt put pwd q
queue quit rd recurse reget
rename reput rm rmdir setmode
stat symlink tar tarmode translate
vuid logon !
指令不少,但是看上去和ftp有很多的相同的地方,我們輸入ls就可以檢視共享檔案了,同時也可以使用cd來切換目錄,同時可以用get指令下載下傳檔案put上傳檔案等等的操作了,具體的就不操作了。
下面就是共享目錄的備份了,我們輸入指令
[root@localhost /]# smbtar
Usage: smbtar [<options>] [<include/exclude files>]
Function: backup/restore a Windows PC directories to a local tape file
Options: (Description) (Default)
-r Restore from tape file to PC Save from PC to tapefile
-i Incremental mode Full backup mode
-a Reset archive bit mode Don't reset archive bit
-v Verbose mode: echo command Don't echo anything
-s <server> Specify PC Server
-p <password> Specify PC Password
-x <share> Specify PC Share backup
-X Exclude mode Include
-N <newer> File for date comparison
-b <blocksize> Specify tape's blocksize
-d <dir> Specify a directory in share /
-l <log> Specify a Samba Log Level 2
-u <user> Specify User Name root
-t <tape> Specify Tape device tar.out
Please enter a command line parameter!
具體的使用是smbtar -s 192.168.0.1 -u redhat -p redhat -x cnbird -t cnbird.tar
本來以為結束了,但是一看沒有成功,後來檢視資料發現是smbtar這個工具有問題的,我們來看一下解決方法
[root@localhost /]# locate smbtar
warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old
/usr/share/man/man1/smbtar.1.gz
/usr/share/doc/samba-3.0.10/htmldocs/smbtar.1.html
/usr/bin/smbtar
[root@localhost /]# file /usr/bin/smbtar
/usr/bin/smbtar: Bourne shell script text executable
smbtar是一個腳本檔案,我們最後一行的内容
eval $SMBCLIENT "'////$server//$service'" "'$password'" -U "'$username'" /
-E $log -D "'$cdcmd'" ${clientargs} /
哈哈我下載下傳的最新的版本已經修改過這個Bug了,以前的是把-N的指令去掉。