我在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下载这个文件,而无需询问密码。
有什么想法吗?
谢谢。
它在FileZilla中工作,因为FileZilla默认为被动FTP模式,这对防火墙/NAT更友好。在任何版本的Windows上,Windows FTP命令行客户端(ftp.exe
)不仅默认为主动模式,甚至不支持被动模式。由于无处不在的防火墙和NAT,现在它变得非常无用。
阅读我关于主动和被动FTP连接模式的文章,了解为什么被动模式是必须的。
请改用任何其他Windows FTP命令行客户端。大多数其他支持被动模式。
例如,WinSCP默认为被动模式,并且有一个指南可用于将Windows FTP脚本转换为WinSCP脚本。
您可以特别使用批处理文件(.bat
),如:
winscp.com /command ^
"open ftp://my_username:password@1.2.3.4/" ^
"get setup.exe" ^
"exit"
(我是WinSCP的作者)