2

So I've got an interesting issue at the moment. I'm attempting to use curl (7.15.5 on CentOS) to retrieve a file from a remote FTP server. Our client changed something last weekend, because it worked on Friday and doesn't now.

I can FTP in using the CLI client, and get a directory listing just fine, although I have to issue "passive" to turn passive mode off. If I don't, I get

421 Service not available, remote server has closed connection
Passive mode refused.  Turning off passive mode.
No control connection for command: Transport endpoint is not connected
ftp> 

Alright. Obviously, passive mode needs to be disabled. I've read the man page a few times and I understand that I need to use -P to specify "active" mode, however from the documentation it seems like this will open a port on the client (my) machine for the data to stream to. Since it's behind a firewall, this won't work.

This tells me that I misunderstand something, because the CLI client works in active mode.

Help me serverfault-kenobi, you're my only hope.

Matt Simmons
  • 20,584

3 Answers3

1

This link explains Active vs Passive very well.

Kyle Brandt
  • 85,693
1

I got it!

The key is to use -P, but you've got to use the "obvious" choice, since you can't open another port and have it connect in.

To quote the documentation:

- make curl pick the same IP address that is already used for the control connection

So the curl command

curl -u username:password -P - -o output.file ftp://whatever/source.file

The -P - was the important part. Essentially it makes curl use the only available connection (the command connection) for transferring data.

Hurray!

Matt Simmons
  • 20,584
0

For me - to make it work - I also had to add --disable-eprt as well:

curl --disable-eprt -u username:password -P - ftp://whatever/source.file
Nik
  • 101