Accessing FTP server behind a proxy via command pr

2020-06-21 04:43发布

问题:

I want to connect to the FTP server ftp://trmmopen.gsfc.nasa.gov/pub/merged/3B42RT from my command prompt in Windows 7.

It's always showing not connected.

I am running my PC behind proxy. I came to know about port error. Followed this solution here about port forwarding but still no result.

回答1:

Windows built-in command-line ftp.exe client does not support connecting over a proxy. It also supports an active mode only, what makes it difficult to connect though proxy anyway (even if some transparent proxy solution is used).

You have to use a 3rd party command-line FTP client that supports a passive mode and a proxy.

For example with WinSCP FTP client, you can use the following batch file (.bat):

WinSCP.com /command ^
    "open ftp://anonymous:dummy@trmmopen.gsfc.nasa.gov/ -rawsettings ProxyMethod=3 ProxyHost=proxy ProxyUsername=username ProxyPassword=password" ^
    "cd /pub/merged/3B42RT" ^
    "ls" ^
    "exit"

See a guide to scripting with WinSCP and a guide for converting Windows FTP script to WinSCP script.

The above code is for an HTTP proxy. If you use a different proxy type, alter the ProxyMethod setting accordingly. See https://winscp.net/eng/docs/rawsettings

Though easier is to configure the connection in WinSCP GUI and then have it generate a script template for you.

(I'm the author of WinSCP)