Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP command in Windows hangs with "150 Opening data channel for file download from server of ..."

I have a FTP server on a Windows Server 2012 machine and I am trying to get setup.exe from it.

CMD.EXE log:

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 ([email protected])
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 log 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 ([email protected])
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 log:

Status: Connection established, waiting for welcome message...
Response:   220-FileZilla Server version 0.9.45 beta
Response:   220-written by Tim Kosse ([email protected])
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

Why it works with FileZilla but not with Windows FTP from command-line?

More than that I would want a command that executed one time would download this file from that FTP without asking the password.

Any ideas?

Thanks.

like image 373
Danio Varacovic Avatar asked Dec 13 '25 08:12

Danio Varacovic


1 Answers

It works in FileZilla, because FileZilla defaults to the passive FTP mode, which is more firewall/NAT friendly. The Windows FTP command-line client (ftp.exe) not only defaults to the active mode, it does not even support the passive mode, on any version of Windows. It makes it pretty useless nowadays due to ubiquitous firewalls and NATs.

Read my article about the active and passive FTP connection modes to understand why the passive mode is a must.


Use any other 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.

Your can specifically use a batch file (.bat) like:

winscp.com /command ^
    "open ftp://my_username:[email protected]/" ^
    "get setup.exe" ^
    "exit"

(I'm the author of WinSCP)

like image 92
Martin Prikryl Avatar answered Dec 15 '25 05:12

Martin Prikryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!