Problem: When trying to list the contents of a directory on a public FTP server from a host in the Amazon EC2 cloud the FTP client hangs. This can be from using ls in command line or simply logging in with an FTP client like WinSCP and getting the error:
“Timeout detected.
Could not retrieve directory listing
Opening ASCII mode data connection for file list.
Error listing directory ‘/’.”
Solution: Amazon EC2 host are behind a firewall which requires passive FTP. Check a box in your FTP client to force passive mode or if using command line or scripts enter the command “literal pasv” before listing the directory contents as shown below:
C:\Windows\System32>ftp
ftp> open ftp.publicftpserver.com
Connected to ftp.publicftpserver.com
220 EFT Server 6.2.7 Build 05.03.2010.3
User (ftp.publicftpserver.com:(none)): youruser
331 Password required for youruser.
Password:
230 Login OK. Proceed.
ftp> literal pasv
227 Entering Passive Mode (10,201,1,53,18,114).
ftp> ls
200 Command okay.
150 Opening ASCII mode data connection for file list.
file1
file2
file3
226 Transfer complete. 62 bytes transferred. 62 bps.
ftp: 62 bytes received in 0.00Seconds 62.00Kbytes/sec.
ftp>