Ftp
從 ftp 下載時,Curl 凍結
我正在嘗試使用以下命令從 ftp 伺服器下載文件
curl
:curl --user kshitiz:pAssword ftp://@11.111.11.11/myfile.txt -o /tmp/myfile.txt -v
curl
連接到伺服器並凍結:* Hostname was NOT found in DNS cache * Trying 11.111.11.11... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to 11.111.11.11 (11.111.11.11) port 21 (#0) < 220-You Are Attempting To Access a Private < 220-Network. Unauthorized Access is Strictly < 220-Forbidden. Violators Will be Prosecuted! < 220-- Management < 220 This is a private system - No anonymous login > USER kshitiz < 331 User kshitiz OK. Password required > PASS pAssword < 230-OK. Current directory is / < 230 4432718 Kbytes used (54%) - authorized: 8192000 Kb > PWD < 257 "/" is your current location * Entry path is '/' 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0> EPSV * Connect data stream passively * ftp_perform ends with SECONDARY: 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:02 --:--:-- 0< 229 Extended Passive mode OK (|||10653|) * Hostname was NOT found in DNS cache * Trying 11.111.11.11... * Connecting to 11.111.11.11 (11.111.11.11) port 10653 0 0 0 0 0 0 0 0 --:--:-- 0:00:03 --:--:-- 0* Connected to 11.111.11.11 (11.111.11.11) port 21 (#0) > TYPE A 0 0 0 0 0 0 0 0 --:--:-- 0:04:02 --:--:-- 0^C
但是,連接
ftp
並獲取文件是可行的:Status: Connecting to 11.1.1.11:21... Status: Connection established, waiting for welcome message... Response: 220-You Are Attempting To Access a Private Response: 220-Network. Unauthorized Access is Strictly Response: 220-Forbidden. Violators Will be Prosecuted! Response: 220-- Management Response: 220 This is a private system - No anonymous login Command: USER kshitiz Response: 331 User kshitiz OK. Password required Command: PASS ****** Response: 230-OK. Current directory is / Response: 230 4432718 Kbytes used (54%) - authorized: 8192000 Kb Status: Server does not support non-ASCII characters. Status: Connected Status: Starting download of /myfile.txt Command: CWD / Response: 250 OK. Current directory is / Command: PWD Response: 257 "/" is your current location Command: TYPE I Response: 200 TYPE is now 8-bit binary Command: PASV Response: 227 Entering Passive Mode (10,9,4,66,39,139) Command: RETR myfile.txt Response: 150 Accepted data connection Response: 226-File successfully transferred Response: 226 0.000 seconds (measured here), 3.39 Kbytes per second Status: File transfer successful, transferred 1 B in 1 second
命令怎麼處理
TYPE A
?為什麼當 ftp 起作用時 curl 不起作用?
添加
--disable-epsv
開關解決了這個問題。一點解釋:
我剛剛經歷了許多小時試圖找出奇怪的 FTP 問題。問題出現的方式是登錄後,當 FTP 客戶端嘗試目錄列表(或任何其他命令)時,它就會掛起。EPSV 是“擴展被動模式”,是 FTP 歷史被動模式 (PASV) 的更新擴展……最近的 FTP 客戶端首先嘗試 EPSV,然後僅在失敗時使用傳統的 PASV。…如果防火牆阻止EPSV,客戶端會認為命令成功[並繼續等待響應]。
在這裡閱讀更多。