SFTP使用WinSCP
WinSCP目前是免費的FTP軟體
1. 到WinSCP網站下載WinSCP.exe
http://winscp.net/eng/download.php
2.產生Ftp.bat檔,檔案內容如下:
winscp.exe /console /script="C:\winscp\winscp-script.txt"
3.產生winscp-script.txt檔,檔案內容如下:
option batch abort
option confirm off
option transfer binary
open sftp://LoginID:LogPwd@FTP_Host -hostkey="ssh-rsa 1024 XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:X:XX:XX:XX:XX"
put d:\examplefile.txt
close
exit
說明:open sftp://登入帳號:登入密碼@FTP位址
-hostkey 用WINSCP.EXE連線後,在下圖紅框點兩下即可顯示
put 上傳檔案的本機路徑
另外說明 scp及ftps的語法:
winscp.exe scp://test@example.com:2222 /privatekey=mykey.ppk
winscp.exe ftps://martin@example.com /implicit /certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
若寫在winscp-script.txt檔內則為
open scp://test@example.com:2222 /privatekey=mykey.ppkopen ftps://martin@example.com /implicit /certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
4.將WinSCP.exe、Ftp.bat、winscp-script.txt放在同一個目錄
5.執行Ftp.bat :將Ftp.bat 點兩下即開始執行