4

I'm having trouble setting up FTP between my host OS (Windows 7) and guest OS (Ubuntu 10.04). I used the network settings in VirtualBox to setup port forwarding on 80, 21, and 22. Accessing the webserver on port 80 works great but I'm having some problems with FTP on port 21 and SFTP on 22.

This is the output when I try connecting on port 21 in FileZilla:

Status: Connecting to 127.0.0.1:21...
Status: Connection established, waiting for welcome message...
Response:   220 (vsFTPd 2.2.2)
Command:    USER menuplus
Response:   331 Please specify the password.
Command:    PASS *****
Response:   230 Login successful.
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/srv/www/vhosts/mp"
Command:    TYPE I
Response:   200 Switching to Binary mode.
Command:    PASV
Response:   227 Entering Passive Mode (10,0,2,15,205,164).
Command:    LIST
Error:  Connection timed out
Error:  Failed to retrieve directory listing

A connection is established, but the LIST command fails which makes me thing maybe the permissions on the guest OS are setup wrong, but the FTP user has full access to its home directory.

What could be wrong?

1 Answer 1

3
Command:    PASV
Response:   227 Entering Passive Mode (10,0,2,15,205,164).
Command:    LIST
Error:  Connection timed out

The error message is "Connection timed out", as you can hopefully see. If there was a permission problem, LIST would immediately fail with a "Access denied" or "Permission denied" response from the remote side.

FTP does not work well with NATs. It uses separate control and data connections – and each time a data connection is needed, the FTP client must connect to the address provided by the server's PASV result. In this case, your server tells the client to connect to 10.0.2.15 for LIST output – this does not work due to your virtual machine being behind the VirtualBox NAT. (More advanced NAT implementations, such as those found in home routers, "adjust" the FTP traffic to work around this.)

Your choices are to use VirtualBox "bridged" networking, which makes your VM part of the real network, or to use SFTP, which always uses a single control/data connection and should not have the same problem.

1
  • 1
    Well there's another option and still being behind NAT. Configure the guest FTP server like serverfault.com/a/165468/126443 . Where the address will be 127.0.0.1 and port range should allow only 1 or 2 ports (ie 10000-10001). Then simply forward ports 21,10000 and 10001 from host machine to guest.
    – antitoxic
    Commented Sep 30, 2012 at 14:39

You must log in to answer this question.