共享 Windows 磁盘给 Linux 机器
一种给 UNIX 机器用的 SMB client 程序被包含在 Samba 发行套件之中.它提供一种在命令列下的像ftp的界面.
想要看在给定的主机上有哪些共享可取得, 执行:
--------------------------------------------------------------------------------
/usr/sbin/smbclient -L host
--------------------------------------------------------------------------------
这里的 'host' 是你想要浏览的机器名子. 这将会响应一串 'service' 的域名 - 也就是, 它所共享给你的磁盘或打印机的域名. 除非 SMB 服务器没有安全上的设定, 否则它将要求你输入密码. 给它 'guest' 帐号的密码或是你个人在那台机器上帐号的密码.
举个例子:
--------------------------------------------------------------------------------
smbclient -L zimmerman
--------------------------------------------------------------------------------
这个指令的输出应该看起来像是这样:
--------------------------------------------------------------------------------
Server time is Sat Aug 10 15:58:27 1996
Timezone is UTC+10.0
Password:
Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]
Server=[ZIMMERMAN] User=[] Workgroup=[WORKGROUP] Domain=[]
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk Remote Admin
public Disk Public
C$ Disk Default share
IPC$ IPC Remote IPC
OReilly Printer OReilly
print$ Disk Printer Drivers
This machine has a browse list:
Server Comment
--------- -------
HOPPER Samba 1.9.15p8
KERNIGAN Samba 1.9.15p8
LOVELACE Samba 1.9.15p8
RITCHIE Samba 1.9.15p8
ZIMMERMAN
--------------------------------------------------------------------------------
这个 browse list 列出其它有资源共享给网络的 SMB 服务器.
要使用此 client, 请执行:
--------------------------------------------------------------------------------
/usr/sbin/smbclient service <password>
--------------------------------------------------------------------------------
这里的 'service' 是一台机器和共享域名. 举例而言,如果你设法连到一台叫做 zimmerman 的机器上之以 'public' 为共享域名的目录 ,此 service 要叫做 \zimmermanpublic. 然而,因为 shell 限制, 你会需要脱离 backslashes, 所以你要像这样的结束:
--------------------------------------------------------------------------------
/usr/sbin/smbclient \\\\zimmerman\\public mypasswd
--------------------------------------------------------------------------------
这样的 'mypasswd' 是你的密码之文字串{literal string}.
你将会有 smbclient 的提示符号{prompt}出现:
--------------------------------------------------------------------------------
Server time is Sat Aug 10 15:58:44 1996
Timezone is UTC+10.0
Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]
smb: \>
--------------------------------------------------------------------------------
键入 'h' 取得关于使用 smbclient 的 help:
--------------------------------------------------------------------------------
smb: \> h
ls dir lcd cd pwd
get mget put mput rename
more mask del rm mkdir
md rmdir rd prompt recurse
translate lowercase print printmode queue
cancel stat quit q exit
newer archive tar blocksize tarmode
setmode help ? !
smb: \>
--------------------------------------------------------------------------------
如果你能使用ftp,你应该不需要查询 smbclient 的 man pages.
下面是通过grape上访问我的机器里面的共享文件夹。并获得两个文件的过程。
[hanhj@grape hanhj]$ smbclient -L hanhj
added interface ip=211.71.6.247 bcast=211.71.6.255 nmask=255.255.255.192
Got a positive name query response from 211.71.6.215 ( 211.71.6.215 )
Password:
Domain=[WORKGROUP] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
E$ Disk 默认共享
IPC$ IPC 远程 IPC
D$ Disk 默认共享
Debug Disk
G$ Disk 默认共享
F$ Disk 默认共享
ADMIN$ Disk 远程管理
C$ Disk 默认共享
Server Comment
--------- -------
Workgroup Master
--------- -------
[hanhj@grape hanhj]$ smbclient \\\\hanhj\Debug
added interface ip=211.71.6.247 bcast=211.71.6.255 nmask=255.255.255.192
Usage: smbclient service <password> [options]
Version 2.2.7a
-s smb.conf pathname to smb.conf file
-O socket_options socket options to use
-R name resolve order use these name resolution services only
-M host send a winpopup message to the host
-i scope use this NetBIOS scope
-N don't ask for a password
-n netbios name. Use this name as my netbios name
-d debuglevel set the debuglevel
-P connect to service as a printer
-p port connect to the specified port
-l log basename. Basename for log/debug files
-h Print this help message.
-I dest IP use this IP to connect to
-E write messages to stderr instead of stdout
-U username set the network username
-L host get a list of shares available on a host
-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}
-m max protocol set the max protocol level
-A filename get the credentials from a file
-W workgroup set the workgroup name
-T<c|x>IXFqgbNan command line tar
-D directory start from directory
-c command string execute semicolon separated commands
-b xmit/send buffer changes the transmit/send buffer (default: 65520)
\hanhjDebug: Not enough '\' characters in service
[hanhj@grape hanhj]$ smbclient \\\\hanhj\\Debug
added interface ip=211.71.6.247 bcast=211.71.6.255 nmask=255.255.255.192
Got a positive name query response from 211.71.6.215 ( 211.71.6.215 )
Password:
Domain=[WORKGROUP] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \> help
? altname archive blocksize cancel
cd chmod chown del dir
du exit get help history
lcd link lowercase ls mask
md mget mkdir more mput
newer open print printmode prompt
put pwd q queue quit
rd recurse rename rm rmdir
setmode symlink tar tarmode translate
!
smb: \> ls
. D 0 Fri Mar 25 18:08:54 2005
.. D 0 Fri Mar 25 18:08:54 2005
vc60.idb A 156672 Fri Mar 25 18:07:08 2005
vc60.pdb A 102400 Mon Jan 10 23:35:04 2005
WinMsgDll.bsc A 1991680 Mon Jan 10 23:35:04 2005
WinMsgDll.dll A 204854 Mon Jan 10 23:35:04 2005
WinMsgDll.exp A 746 Tue Jan 4 23:58:02 2005
WinMsgDll.ilk A 261308 Mon Jan 10 23:35:04 2005
WinMsgDll.lib A 2094 Tue Jan 4 23:58:02 2005
WinMsgDLL.obj A 13124 Mon Jan 10 23:35:04 2005
WinMsgDll.pch A 4714204 Mon Jan 10 23:35:04 2005
WinMsgDll.pdb A 631808 Mon Jan 10 23:35:04 2005
WinMsgDLL.sbr A 0 Mon Jan 10 23:35:04 2005
59934 blocks of size 262144. 8213 blocks available
smb: \> help get
HELP get:
<remote name> [local name] get a file
smb: \> get vc60.pdb
getting file \vc60.pdb of size 102400 as vc60.pdb (2222.2 kb/s) (average 2222.2 kb/s)
smb: \>
smb: \> get *.lib
NT_STATUS_OBJECT_NAME_INVALID opening remote file \*.lib
smb: \> get WinMsgDll.lib
getting file \WinMsgDll.lib of size 2094 as WinMsgDll.lib (681.6 kb/s) (average 2125.9 kb/s)
smb: \>q
[hanhj@grape hanhj]$