Curl congela ao fazer o download do ftp

2

Estou tentando baixar um arquivo do servidor ftp usando curl :

curl --user kshitiz:pAssword ftp://@11.111.11.11/myfile.txt -o /tmp/myfile.txt -v

curl se conecta ao servidor e congela:

* 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

Conectar-se com ftp e buscar um arquivo funciona, no entanto:

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

Qual é o problema com o comando TYPE A ? Por que a ondulação não funciona quando o ftp funciona?

    
por Kshitiz Sharma 16.07.2015 / 16:48

3 respostas

4

A adição da opção --disable-epsv corrigiu o problema.

Uma pequena explicação:

I just went through many hours of trying to figure out wierd FTP problems. The way that the problem presented was that after login, when the FTP client attempted a directory listing (or any other command), it would just hang. EPSV is "extended passive mode", and is a newer extension to FTP's historical passive mode (PASV) ... most recent FTP clients attempt EPSV first, and then only use the traditional PASV if it fails. ... if the firewall is blocking EPSV, the client will think that the command is successful [and keep waiting for response].

Leia mais aqui .

    
por 16.07.2015 / 18:44
1

Exemplo de documento 'here' depois de criar um ~ / .netrc com conexões / usuários / senhas.

 #!/bin/bash
 ftp 11.1.1.11 << eof
        ascii
        get /tmp/myfile.txt
        bye
 eof

Pitty você não pode usar lftp, é um ótimo cliente e não vejo nenhuma diferença de segurança entre ter suas senhas em ~ / .netrc ou tê-las no script se você der as permissões corretas.

    
por 16.07.2015 / 17:55
0

O problema é com o servidor ftp em execução no endereço IP 11.111.11.11.

Isso trava para sempre ...

ftp 11.111.11.11

Primeiro, faça com que o seu servidor ftp funcione com um simples cliente FTP.

Provavelmente isso também consertará seu comando curl.

    
por 16.07.2015 / 18:22

Tags