How to use passive FTP mode in Windows command prompt?

WindowsFtpCommand Prompt

Windows Problem Overview


In Ubuntu ftp -p for passive mode works fine.

How do I do the same in Windows?

I tried with quote pasv but I am getting following error:

230 OK. Current restricted directory is /
ftp> quote pasv 
227 Entering Passive Mode (31,170,167,221,116,239)    
ftp> cd os    
250 OK. Current directory is /os    
ftp> dir    
500 I won't open a connection to 10.23.16.248 (only to 113.193.128.177)    
425 No data connection    
ftp>

My firewall is disabled.

Windows Solutions


Solution 1 - Windows

The Windows FTP command-line client (ftp.exe) does not support the passive mode, on any version of Windows. It makes it pretty useless nowadays due to ubiquitous firewalls and NATs.

Using the quote pasv won't help. It switches only the server to the passive mode, but not the client.


Use any thirdparty Windows FTP command-line client instead. Most other support the passive mode.

For example WinSCP defaults to the passive mode and there's a guide available for converting Windows FTP script to WinSCP script. If you are starting from the scratch, see the guide to automating file transfers to FTP using WinSCP. Also, WinSCP GUI can generate a script template for you.

(I'm the author of WinSCP)

Solution 2 - Windows

Windows does not actually support passive mode.

You can send the command to the server in three different ways but that will not enable passive mode on the Windows client end.

Those arguments are for sending various commands and pasv is not something that Microsoft thought of when they wrote it.

You will have to find a 3rd party software like WinSCP that supports command line usage and use that instead of the Windows native one.

Solution 3 - Windows

Although this doesnt answer the question directly about command line, but from Windows OS, use the Windows Explorer ftp://username@server

this will use Passive Mode by default

For command line, active mode is the default

Solution 4 - Windows

The quote PASV command is not a command to the ftp.exe program, it is a command to the FTP server requesting a high order port for data transfer. A passive transfer is one in which the FTP data over these high order ports while control is maintained in the lower ports.

The windows ftp.exe program can be used to send the FTP server commands to make a passive data transfer between two FTP servers. A standard windows installation will not, and probably should not, have FTP server service running as an endpoint for passive transfers. So if passive transfers are needed with a standard windows box, a solution other than ftp.exe is necessary as FTPing to localhost as one of the connections won't work in most windows environments.

You can effect a passive FTP transfer between two different hosts (but not two connections on the same host) as follows:

Open up two prompts, use one to ftp.exe connect to your source FTP server and one to ftp.exe connect to your destination FTP server.

Now establish a passive connection between the servers using the raw commands PASV and PORT. The quote PASV command will respond with an IP/port in ellipsis. Use that data for the quote PORT <data> command. Your passive link is now established assuming that firewalls haven't blocked one or more of the four ports (2 for FTP control, 2 for FTP data)

Next start receive of data with the quote STOR <filename> command to the receiving FTP server then send the control command quote RETR <filename> to the source FTP server.

so for me:

client 1
> ftp.exe server1
ftp> quote PASV
227 Entering Passive Mode (10,0,3,1,54,161)

client 2 
> ftp.exe server2
ftp> quote PORT 10,0,3,1,54,54,161
ftp> quote STOR myFile

client 1
ftp> quote RETR myFile

Cavet: I'm connecting to some old FTP servers YMMV

Solution 5 - Windows

CURL client supports FTP protocol and works for passive mode. Get Download WITHOUT SSL version and you don't need any openssl.dll libraries. Just one curl.exe command line application.
http://www.paehl.com/open_source/?CURL_7.35.0
http://www.paehl.com/?CURL_7.79.1

curl.exe -T c:\test\myfile.dat ftp://ftp.server.com/some/folder/myfile.dat --user myuser:mypwd

Another one is Putty psftp.exe but server key verification prompt requires a trick. This command line inputs NO for prompt meaning key is not stored in registry just this time being used. You need an external script file but sometimes its good if you copy multiple files up and down.
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

echo n | psftp.exe ftp.server.com -l myuser -pw mypwd -b script.txt

script.txt (any ftp command may be typed)

put "C:\test\myfile.dat" "/some/folder/myfile.dat"
quit

Solution 6 - Windows

If you are using Windows 10, install Windows Subsystem for Linux, WSL and Ubuntu.

$ ftp 192.168.1.39
Connected to 192.168.1.39.
............
230 Logged in successfully
Remote system type is MSDOS.
ftp> passive
Passive mode on.
ftp> passive
Passive mode off.
ftp>

Solution 7 - Windows

According to this Egnyte article, Passive FTP is supported from Windows 8.1 onwards.

The Registry key:

> "HKEY_CURRENT_USER\Software\Microsoft\FTP\Use PASV"

should be set with the value: yes

If you don't like poking around in the Registry, do the following:

  1. Press WinKey+R to open the Run dialog.
  2. Type inetcpl.cpl and press Enter. The Internet Options dialog will open.
  3. Click on the Advanced tab.
  4. Make your way down to the Browsing secction of the tree view, and ensure the Use Passive FTP item is set to on.
  5. Click on the OK button.

Every time you use ftp.exe, remember to pass the

> quote pasv

command immediately after logging in to a remote host.

PS: Grant ftp.exe access to private networks if your Firewall complains.

Solution 8 - Windows

Not really what you are asking, but typing ftp://[email protected] in the searchbar in the standard windows explorer (filemanager, not internet browser) opens the ftp-server as a regular folder you can browse and use as normally.

Solution 9 - Windows

For passive mode you need to use command "literal" ftp>literal PASV

Solution 10 - Windows

FileZilla Works well. I Use FileZilla FTP Client "Manual Transfer" which supports Passive mode.

Example: Open FileZilla and Select "Transfer" >> "Manual Transfer" then within the Manual Transfer Window, perform the following:

  1. Confirm proper Download / Upload option is selected
  2. For Remote: Enter name of directory where the file to download is located
  3. For Remote: Enter the name of the file to be downloaded
  4. For Local: Browse to desired directory you want to download file to
  5. For Local: Enter a file name to save downloaded file As (use same file name as file to be downloaded unless you want to change it)
  6. Check-Box "Start transfer immediately" and Click "OK"
  7. Download should start momentarily
  8. Note: If you forgot to Check-Box "Start transfer immediately"... No Problem: just Right-Click on the file to be downloaded (within the Process Queue (file transfer queue) at the bottom of the FileZilla window pane and Select "Process Queue"
  9. Download process should begin momentarily
  10. Done

Solution 11 - Windows

This is a common problem . when we start the ftp connection only the external ip opens the port for pasv connection. but the ip behind the NAT doesn't open the connection so passive connection fails with PASV command

we need to specify that while opening the connection so open connection with

ftp -p {host}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2737208View Question on Stackoverflow
Solution 1 - WindowsMartin PrikrylView Answer on Stackoverflow
Solution 2 - WindowstransilvladView Answer on Stackoverflow
Solution 3 - WindowsHammadView Answer on Stackoverflow
Solution 4 - WindowsBruce PetersonView Answer on Stackoverflow
Solution 5 - WindowsWhomeView Answer on Stackoverflow
Solution 6 - WindowsJaeMann YehView Answer on Stackoverflow
Solution 7 - WindowsJohn O'ReganView Answer on Stackoverflow
Solution 8 - WindowsLeif NelandView Answer on Stackoverflow
Solution 9 - WindowsSlavView Answer on Stackoverflow
Solution 10 - WindowsRon ArndtView Answer on Stackoverflow
Solution 11 - WindowsAshutosh RajView Answer on Stackoverflow