Here is the scenario:
- We have one AWS Ubuntu server Server
- This server is working as ftp client
- Now when we try to connect to XYZ companies ftp server using this AWS server as client, it is sending it's local LAN IP while connecting to the ftp server, because of which listing of directories does not work.
- Log shows that we are connected to the FTP server + we are authenticated correctly... port listing goes successful + only directory listing fails.
- we can provide specific IP in FTP using filezilla which it will use while going out of the gateway.
- here we can't use that because it does not have GUI & it is going to be used by a php script.
- This problem was also there in windows at that time we solved it by giving a elastic IP to FileZilla. before the solution we used to receive the error & log showed like This. this point is added just to give you more details. & it's the same issue with Ubuntu & we want to give a elastic IP somewhere in ftp so that it will start working... we hope so at least. ;)
Recent updates
please click here for vsftpd.conf file.
little more clarification :
In this case machine "A" is our FTP Server (which is AWS Ubuntu server) for internal usage, because of the lot of other process and data which is regularly uploaded on this FTP Server (Machine "A") & Machine "B" is our client's FTP Server which they use for their internal purposes. Now we need to pull some data from our clients FTP Server (i.e. Machine "B") to our server (i.e. Machine "A") and then process it. after that we need to put the processed data back on to the client's FTP Server (i.e. Machine "B"). that's what is not working
Logs of clients firewall when we tried to connect with machine "B" as shown in below image.
Add to your vsftpd config (/etc/vsftpd.conf):
In the security config of your instance open port 20-21 for FTP, also enable passive ports to the range you specified above (pasv_min/max_port, eg: 64000-64100).
Restart vsftpd.
if that doesn't work you can try to replace the last two lines with:
This is my understanding of your scenario:
FTP works in two modes:
- Active Mode -
In active mode FTP, the client connects from a random unprivileged port (N > 1023) to the FTP server's command port, port 21. Then, the client starts listening to port N+1 and sends the FTP command PORT N+1 to the FTP server. The server will then connect back to the client's specified data port (...)
Example:
- Passive Mode -
In passive mode FTP, the client initiates both connections to the server, solving the problem of firewalls filtering the incoming data port connection to the client from the server. When opening an FTP connection, the client opens two random unprivileged ports locally (N > 1023 and N+1). The first port contacts the server on port 21, but instead of then issuing a PORT command and allowing the server to connect back to its data port, the client will issue the PASV command. The result of this is that the server then opens a random unprivileged port (P > 1023) and sends P back to the client in response to the PASV command. The client then initiates the connection from port N+1 to port P on the server to transfer data. (...)
Example:
These are the solutions you have:
Now you should be able to "ls".
You can read more about how FTP works here: http://slacksite.com/other/ftp.html
This page is also good to understand the FTP modes: http://www.deskshare.com/resources/articles/ftp-how-to.aspx
refs: https://ubuntu.com/server/docs/service-ftp, https://ubuntu.com/server/docs/security-users