【问题标题】:FTP command in Windows hangs with "150 Opening data channel for file download from server of ..."Windows 中的 FTP 命令挂起并显示“150 从...的服务器打开文件下载的数据通道”
【发布时间】:2016-09-02 17:45:56
【问题描述】:

我在 Windows Server 2012 机器上有一个 FTP 服务器,我正在尝试从中获取 setup.exe

CMD.EXE 日志:

C:\>ftp 1.2.3.4
Connected to 1.2.3.4.
220-FileZilla Server version 0.9.45 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit http://sourceforge.net/projects/filezilla/
User (1.2.3.4:(none)): my_username
331 Password required for my_username
Password:
230 Logged on
ftp> get setup.exe
200 Port command successful
150 Opening data channel for file download from server of "/setup.exe"
.. and stays like this

CMD.EXE 日志 2:

C:\>ftp 1.2.3.4
Connected to 1.2.3.4.
220-FileZilla Server version 0.9.45 beta
220-written by Tim Kosse (tim.kosse@filezilla-project.org)
220 Please visit http://sourceforge.net/projects/filezilla/
User (1.2.3.4:(none)): my_username
331 Password required for my_username
Password:
230 Logged on
ftp> quote cwd /
250 CWD successful. "/" is current directory.
ftp> quote TYPE I
200 Type set to I
ftp> QUOTE PASV
227 Entering Passive Mode (185,7,63,37,115,151)
ftp> RETR setup.exe
Invalid command.
ftp> QUOTE RETR setup.exe
425 Can't open data connection for transfer of "/setup.exe"
ftp> get setup.exe
200 Port command successful
150 Opening data channel for file download from server of "/setup.exe"
Aborting any active data connections...
Aborting any active data connections...
Connection closed by remote host.
ftp> quote get setup.exe
Not connected.
ftp>

FileZilla 日志:

Status: Connection established, waiting for welcome message...
Response:   220-FileZilla Server version 0.9.45 beta
Response:   220-written by Tim Kosse (tim.kosse@filezilla-project.org)
Response:   220 Please visit http://sourceforge.net/projects/filezilla/
Command:    AUTH TLS
Response:   502 SSL/TLS authentication not allowed
Command:    AUTH SSL
Response:   502 SSL/TLS authentication not allowed
Status: Insecure server, it does not support FTP over TLS.
Command:    USER my_username
Response:   331 Password required for my_username
Command:    PASS **************
Response:   230 Logged on
Status: Logged in
Status: Starting download of /setup.exe
Command:    CWD /
Response:   250 CWD successful. "/" is current directory.
Command:    TYPE I
Response:   200 Type set to I
Command:    PASV
Response:   227 Entering Passive Mode (185,7,63,37,98,242)
Command:    RETR setup.exe
Response:   150 Opening data channel for file download from server of "/setup.exe"
Response:   226 Successfully transferred "/setup.exe"
Status: File transfer successful, transferred 5,120 bytes in 1 second

为什么它适用于 FileZilla,但不适用于命令行中的 Windows FTP?

除此之外,我还想要一个执行一次的命令会从该 FTP 下载此文件而无需询问密码。

有什么想法吗?

谢谢。

【问题讨论】:

    标签: windows batch-file cmd ftp


    【解决方案1】:

    它在 FileZilla 中工作,因为 FileZilla 默认为被动 FTP 模式,这对防火墙/NAT 更友好。 Windows FTP 命令行客户端 (ftp.exe) 在任何版本的 Windows 上不仅默认为主动模式,甚至不支持被动模式。由于无处不在的防火墙和 NAT,它现在变得非常无用。

    阅读我关于active and passive FTP connection modes 的文章,了解为什么必须使用被动模式。


    请改用任何其他 Windows FTP 命令行客户端。其他大多数都支持被动模式。

    例如WinSCP 默认为被动模式,并且有一个可用于转换Windows FTP script to WinSCP script 的指南。

    您可以专门使用批处理文件 (.bat),例如:

    winscp.com /command ^
        "open ftp://my_username:password@1.2.3.4/" ^
        "get setup.exe" ^
        "exit"
    

    (我是 WinSCP 的作者)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-11
      • 2020-02-06
      • 1970-01-01
      • 1970-01-01
      • 2014-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多