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.

on my win 7 32 bit QUOTE PASV or quote pasv doesn't work. After issuing the command it does say227 Entering Passive Modebut 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.

About Me

My technical passion is for building consumer software applications. I'm best known for my work in Windows and C++, but lately I've been working on cross platform Android/iPhone mobile solutions in Flutter and Dart.

My book Multithreading Applications Win32 was one of the top 3 best-selling books on Amazon on Windows development for over five years. I've been the architect of software projects for Google, Intel, Brother, Northrop Grumman, and numerous smaller companies.

Click "Email" in my profile to contact me.

I have been writing commercial software for Microsoft operating systems since MS-DOS 1.0. I am published in magazines such as Dr. Dobbs Journal, C++ Users Journal, and Visual C++ Developers Journal. I am in the Giant List of Classic Game Programmers.