FTP connection command fails - ftp

Ftp via Terminal works perfectly if you use the command prompts like this:
Ftp
open
enter hostname
enter username
enter password
But if you attempt to open a connection like this:
ftp ftp://username:password#hostname/path
End up with:
Trying 23.102.24.18...
Connected to waws-prod-db5-091.drip.azurewebsites.windows.net.
220 Microsoft FTP Service
331 Password required
530 User cannot log in.
ftp: Login failed
ftp: Can't connect or login to host waws-prod-db5-091.drip.azurewebsites.windows.net
221 Goodbye.
Any idea why?

Related

AIX 7.1 anonymous ftp fails

I have a "vsftpd" server running on a RHEL machine which is configured for anonymous communication.
I am trying to connect to it from a AIX 7.1 machine using ftp client.
ftp -snv host 8043
Connected to host
220 secure FTP service
ftp> user anonymous mypass
234 Proceed with negotiation.
TLS Auth Entered.
Certificate:
....
....
TLSv1/SSLv3 ( ECDHE-RSA-AES256-GCM-SHA384 ), 256 bits
331 Please specify the password.
230 Login successful.
200 PBSZ set to 0.
200 PROT now Private.
ftp> passive
Passive mode on.
ftp> cd /incoming
250 Directory successfully changed.
ftp> quote pwd
257 "/incoming"
ftp> ls -r
227 Entering Passive Mode (XXX,XXX,XXX,XX,XXX,XX).
ftp: connect: Connection timed out
ftp>
As seen above, the cd and quote pwd command seems to work fine. But ls -r and mput commands fail with Connection timed out error.
No real helpful messages on the server logs also.
Please help on debugging and identifying the issue.
PS: The lftp clients from RHEL work fine connecting to the server.
FTP needs to open two connections to work properly. One for control and one for data.
Whenever you get "cd works but ls doesn't", the data connection is not getting established.
Troubleshooting tips:
look for any firewalls/NATs along the way
try toggling active/passive mode, this opens the data connection from the other side
look at what is happening using network debugging tools like tcpdump/wireshark

Azure FTP login via command line / batch file fails

I am trying to connect by FTP to an Azure Web App. I downloaded the publish profile and copied the login to my FTP client and can connect successfully. But when i use ftp.exe from Windows then i am not able to connect to the same host with the same credentials.
I have read Connecting to Azure website via FTP but those solutions do not fix my problem.
This is the output:
C:\Projects>ftp
ftp> open waws-prod-am2-201.ftp.azurewebsites.windows.net
Connected to waws-prod-am2-201.drip.azurewebsites.windows.net.
220 Microsoft FTP
Service 200 OPTS UTF8 command successful - UTF8 encoding now ON.
User (waws-prod-am2-201.drip.azurewebsites.windows.net:(none)): firstserver\$firstserver
331 Password required
Password:
530 User cannot log in.
Login failed.
Invalid command.
Also tried with username firstserver from the Windows command prompt, no difference. Do not forget: when logging in via commercial FTP client software I CAN login successfully.
I tried backslashing the backslash and/or the dollar sign, but nothing helps. What is going wrong, how do i login from the command prompt using the Windows default ftp.exe?
If you run ftp in debug mode (-d switch), you will see that it truncates the password to 32 characters. That's why the connection fails.
Try using a shorter password. Otherwise you will have to use another command-line FTP client.

How to list FTP directories using telnet? [duplicate]

This question already has an answer here:
Telnet and passive FTP
(1 answer)
Closed 4 years ago.
I installed FileZilla ftp server on one of local server in local network. I can successfully list folders for user user using ftp command (actually I installed Ubuntu in windows 10 through Microsoft store).
ftp -p 192.168.11.24 21
Connected to 192.168.11.24.
220-FileZilla Server 0.9.60 beta
220-written by Tim Kosse (tim.kosse#filezilla-project.org)
220 Please visit https://filezilla-project.org/
Name (192.168.11.24:ms): user
331 Password required for user
Password:
230 Logged on
Remote system type is UNIX.
ftp> nlist /
227 Entering Passive Mode (192,168,11,24,203,217)
150 Opening data channel for directory listing of "/"
/crm-offers-browse-2018-03-08.xlsx
/log_file.txt
/model.png
226 Successfully transferred "/"
If I try the same with telnet (I sniffed the commands using Wireshark) command nlist does not work. It returns 425 Can't open data connection. What am I missing here?
telnet -e _ 192.168.11.24 21
Telnet escape character is '_'.
Trying 192.168.11.24...
Connected to 192.168.11.24.
Escape character is '_'.
220-FileZilla Server 0.9.60 beta
220-written by Tim Kosse (tim.kosse#filezilla-project.org)
220 Please visit https://filezilla-project.org/
USER user
331 Password required for user
PASS user
230 Logged on
SYST
215 UNIX emulated by FileZilla
PASV
227 Entering Passive Mode (192,168,11,24,205,245)
NLST /
425 Can't open data connection for transfer of "/"
The answer is described in this post: Telnet and passive FTP.
You cannot retrieve files over FTP protocol using a Telnet client.
While you can simulate the FTP client by typing FTP commands on a Telnet console, you cannot do file transfers this way. It's because for file transfer you need a separate data transfer connection, what the Telnet client cannot do.
That's why the FTP server fails. In an active mode, it fails to connect back to your client machine, because there's nothing listening. In a passive more, it timeouts waiting for the client to connect to its data port.

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 (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 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 (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 log:
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
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.
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:password#1.2.3.4/" ^
"get setup.exe" ^
"exit"
(I'm the author of WinSCP)

FTP upload in passive mode not working, It opens data connection and times out with "Data channel timed out."

220 Microsoft FTP Service
user user
331 Password required for user.
pass pass
230-Directory has 543,777,456,128 bytes of disk space available.
230 User logged in.
pwd
257 "/" is current directory.
cwd aa6
250 cwd command successful.
pwd
257 "/aa6" is current directory.
pasv
227 Entering Passive Mode (*,*,*,*,201,182).
stor sampleprogram
150 Opening ASCII mode data connection.
425 Data channel timed out.
The above is the FTP done using command-line. When I check with FTP client there is a file with 0 size created.
There's a firewall or NAT between the client and the server that prevents a connection to the port 51638 (= 201 * 2^8 + 182).
If you are not able to transfer files to/from the server from anywhere/any other FTP client, the server was most likely not set up correctly. Particularly the Windows server firewall was not configured with a rule for a data port range. Another option is that the server is not aware of its external IP address. That would be the case, if the part you obfuscated (*,*,*,*) is not the same IP address you connected to.
See my article on FTP Connection Modes for explanation of the network issues with FTP data connection.
And particularly see my article on configuring IIS FTP Server for instructions on configuring the firewall and/or the external IP address.

Resources