Ftp – I have a Windows 2008 R2 Amazon EC2 server, it can’t ls via ftp client, what do I have to do to fix that

amazon ec2ftpgroup-policy

I have a Windows 2008 R2 Amazon EC2 and it needs to download a file from an external server via ftp. The file name is different everyday so I have to ls and then get the newest file. ls fails:

[REDACTED]:\[REDACTED]>ftp [REDACTED]
Connected to [REDACTED].
220 ProFTPD 1.3.3c Server ready.
User ([REDACTED]:(none)): [REDACTED]
331 Password required for [REDACTED]
Password:
230 User [REDACTED] logged in
ftp>ls
Connection closed by remote host.
ftp>

So it takes a while for it to say "Connection closed by remote host." this is what happens when I try on any non-Amazon EC2 Windows 2008 R2 server:

[REDACTED]:\[REDACTED]>ftp [REDACTED]
Connected to [REDACTED].
220 ProFTPD 1.3.3c Server ready.
User ([REDACTED]:(none)): [REDACTED]
331 Password required for [REDACTED]
Password:
230 User [REDACTED] logged in
ftp>ls
200 PORT command successful
150 Opening ASCII mode data connection for file list
photos
tmp
key
logs
customer
reversefeed
reviews
thesaurus
incoming
ad
226 Transfer complete
ftp: 144 bytes received in 0.01Seconds 18.00Kbytes/sec.
ftp>

So just to be clear I'm not running an FTP Server, I am trying to connect to one and download a file. But it is unable to open the data transfer channel. What do I need to change in the Amazon EC2 config for this to work?

Thanks in advance.

Best Answer

This is usually (in my experience) a problem caused by a firewall or filter/proxy on one end of the connection not properly handling PASV (passive) FTP connections. First thing I'd try is using an active FTP connection, and then I'd try to remove the firewall(s) from the equation, which will give you a fairly exact indication of where the issue lies.

And, just as a general point of interest, SFTP (FTP over SSH) does not suffer from this active/passive problem (it's a single, "active" connection), in addition to being a secure, encrypted method of transferring files. You should probably switch to it, if possible. It will probably eliminate your problem, and wrap a layer of security around your file transfers at the same time.