Ubuntu – FileZilla: Failed to retrieve directory listing

filezillaftpvirtualboxvsftpd

I am running Ubuntu 12.04 as the host and installed Ubuntu 14.04 in the Virtualbox as Guest OS.
I have installed and configured VSFTPD on Ubuntu 14.04 and forwarded the virtualbox port's as follows: enter image description here
Now i am using FileZilla in my host OS in order to access into the guest OS.
Here is the FileZilla login detail:
Host: 127.0.0.1
Username: hasan
Password: —–
Port: 8181
Now i press the Quickconnect button to access into the guest os.
Login was success but filezilla was unable to access into the guest os!.
Here is the messages:

Status: Connecting to 127.0.0.1:8181...
Status: Connection established, waiting for welcome message...
Response:   220 (vsFTPd 3.0.2)
Command:    USER hasan
Response:   331 Please specify the password.
Command:    PASS ******
Response:   230 Login successful.
Command:    OPTS UTF8 ON
Response:   200 Always in UTF8 mode.
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/home/hasan"
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PASV
Response:   227 Entering Passive Mode (10,0,2,15,224,245).
Command:    LIST
Error:  Connection timed out
Error:  Failed to retrieve directory listing

I was unable to fix this. Any idea?

Best Answer

Simple port forwarding is not enough for FTP. FTP has a control connection on usually port 21, which you successfully mapped to port 8181. But to transfer files or directory listings FTP opens another connection. There are two ways to open this connection:

  • Passive mode: This is what you use. In this case the FTP server allocates a random port on the server and tells the client IP and port using the response to the passive command. In you case this is "227 Entering Passive Mode (10,0,2,15,224,245)", which means the server waits at IP 10.0.2.15 port 57589. Since the client does not now that 10.0.2.15 is the server and since port 57589 on the server is not accessible from outside the connection will fail.
  • Active mode: Here the client opens a listener on a random port and informs the server about this port. The server will then try to connect from port 20 to this port. This might work if the Ubuntu 14.04 system inside the VirtualBox can access the host system (12.04). If this is possible depends on your setup.

Anyway, FTP is an ugly protocol if port forwardings or firewalls are involved. I would recommend to use sftp instead, which is support by FileZilla too and which only needs a SSH server on the other side (which you probably already have because you forward to port 22).

Related Question