Saturday, October 11, 2008

Passive (PASV) ftp in Windows 7

I was controlling a customer's computer and trying to upload a file to our corporate ftp server. I could connect and log in, but any other command would cause the ftp client to hang. I was using the ftp command built in to XP because I didn't have privileges to install a 3rd party ftp client. It was frustrating, but I didn't have time to debug the problem.

Today I had the same problem on a system in the office when trying to connect to a new server. However, this time I was running a different ftp server (vsftpd) that gave me a helpful error message:

200 PORT command successful. Consider using PASV.

I tried the obvious, which was to restart ftp from the command prompt and then type PASV, but this gave the error "Invalid command." I found several posts that said that the ftp client built-in to Windows doesn't support passive mode. The good news is that they are wrong this is fixed in newer versions of Windows.

With Windows 7, enter this command to enter passive mode:

QUOTE PASV

With vsftpd, I was rewarded with this response, and everything started working:

227 Entering Passive Mode

 
As other have noted in the comments, this does not work on Windows XP.


6 comments:

  1. Thanks.. That was helpful!

    ReplyDelete
  2. This is true, the QUOTE PASV only puts the server into passive mode. While the built in version of windows FTP.exe won't use passive ftp. It always uses active.

    to get around this you need to use a different ftp client such as http://www.passive-ftp.com

    hope that helps someone!

    ReplyDelete
  3. Thanks dude! QUOTE PASV works and resolved an issue I was having downloading a file using the command line ftp in XP. I'll try to remember this in the future.

    ReplyDelete
  4. @Anonymous: this won't help you. You cannot use it with the command-line ftp in XP, because it will only set the FTP-Server to passive mode. The Client still does not support passive mode.

    ReplyDelete
  5. on my win 7 32 bit QUOTE PASV or quote pasv doesn't work. After issuing the command it does say
    227 Entering Passive Mode
    but tcpdump showed that the server is trying to connect back with its port 20 (TCP SYN packet seen) which is how active ftp works.
    So, quote pasv is not actually setting the connection to passive but only showed it on command prompt.

    ReplyDelete
  6. Agree- pasv appears to work, then a subsequent Get command is replied to by PORT successful - boom, back to active.

    ReplyDelete