我都是用samba共享,現在轉載一個用putty共享的文章,可能以后會用到。
From:http://www.veryword.com/2008/08/18/use-putty-to-batch-copy-folder.html
為 了實現在本地的windows和遠程的unix/linux之間進行批量文件傳輸,可以在unix/linux下,通過samba將unix/linux 的硬盤設置為共享,這種辦法的缺點是設置samba時,需要unix/linux管理員的權限。如果unix/linux設置成ftp服務器,也可以通過 windows的ftp命令訪問,這種辦法的缺點是ftp命令只能傳輸單個文件,不能傳輸文件夾,因此需要在傳輸前后進行打包和解包工作。除了這兩種辦法,如果有unix/linux的ssh登陸權限,還可以通過putty進行遠程文件傳輸。
Putty 是免費的綠色的,windows下面的SSH客戶端,除了可以進行遠程登錄,putty所帶的pscp程序還可以實現遠程文件和文件夾傳輸。pscp是命 令行客戶端工具,命令行工具的優點在於簡單,便於調用,和其他的工具,比如宏,結合起來,就可以實現在本地和遠程機器之間批量的文件傳輸。
pscp的一些常用選項包括:
-r 傳輸文件夾
-l 輸入用戶名
-pw 輸入密碼
-1 -2 強制使用某種版本的SSH協議
-C 啟用壓縮
-sftp 強制使用sftp協議
-scp 強制使用scp協議
如果不考慮安全性,而更重視傳輸速度,SSH-1相對SSH-2對cpu的負載要小,SCP協議一般比SFTP協議傳輸得更快。
比如以下命令就可以實現以用戶名username,密碼passwd登陸ip為10.11.44.11的機器,並且把遠程機器/data/下面的putty文件夾下載到本地的ftp目錄:
pscp -r -sftp -l username -pw passwd 10.11.44.11:/data/putty "C:\data\My Documents\ftp"把命令寫到批處理文件中
set PATH=C:\data\My Documents\IAR_review\review\ftp\putty %Set PATH
pscp -r -sftp -l username -pw passwd 10.11.44.11:/data/putty "C:\data\My Documents\ftp"
From: http://www.blogjava.net/lifw/archive/2008/09/03/226679.html
PuTTY 提供的文件傳輸工具PSCP (PuTTY Secure Copy client) 基本使用說明
通過 SSH 連接,在兩台機器之間安全的傳輸文件,可以用於任何 SSH(包括 SSH v1、SSH v2) 服務器。
PSCP 的使用
在控制台直接執行 pscp 可以看到幫助
PuTTY Secure Copy client
Release 0.58
Usage: pscp [options] [user@]host:source target
pscp [options] source [source
] [user@]host:target
pscp [options] -ls [user@]host:filespec
Options:
-V print version information and exit
-pgpfp print PGP key fingerprints and exit
-p preserve file attributes
-q quiet, don't show statistics
-r copy directories recursively
-v show verbose messages
-load sessname Load settings from saved session
-P port connect to specified port
-l user connect with specified username
-pw passw login with specified password
-1 -2 force use of particular SSH protocol version
-4 -6 force use of IPv4 or IPv6
-C enable compression
-i key private key file for authentication
-batch disable all interactive prompts
-unsafe allow server-side wildcards (DANGEROUS)
-sftp force use of SFTP protocol
-scp force use of SCP protocol
可以看出 PSCP 的使用是很簡單的,把常用的幾個選項說一下:
-q 安靜模式,傳輸文件時什么也不顯示,否則會顯示出文件的傳輸進度
-P port 指定服務器的 SSH 端口,注意這個是大寫字母 P,默認是 -P 22,如果主機的 SSH 端口就是 22,就不用指定了
-l user 指定以哪個用戶的身份登錄主機,用戶名稱也可以和主機名稱寫在一起,用@分割開,比如:username@server
-pw passwd 指定登錄時所用的口令為:passwd
-C 表示允許壓縮傳輸,提高傳輸速度
PSCP 基本用法是:
pscp -P 22 -C c:\a.txt username@server:/path/
例子:
1、c:\>pscp -C c:\a.bat username@server:upload/
就是把本地的c:\a.bat復制到了主機server上的用戶username所在的主目錄下的upload子目錄中(這個路徑可能是 /home/username/upload)
2、c:\>pscp -C c:\a.txt username@server:.
把本地的 C:\a.txt 復制到主機server的用戶username的主目錄下
3、c:\>pscp -C username@server:*.tgz c:\download
把遠程主機server上的用戶username主目錄下的所有 *.tgz 文件拷貝到本地的 c:\download目錄中,如果 SSH 版本是 SSH v1,那這個命令就會出錯。
