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.
This link explains Active vs Passive very well.
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
The
-P -
was the important part. Essentially it makes curl use the only available connection (the command connection) for transferring data.Hurray!
For me - to make it work - I also had to add
--disable-eprt
as well: