Troubleshooting FTP connections with PowerShell

I find that helping people troubleshoot FTP connectivity issues is much easier if they have PowerShell installed.  I can just have them run the NetCmdlets ftp cmdlets with the –debug switch, which displays a trail of information about the communication over the wire.  In this way you can see every command send to the server and every response coming back from the server, including what ports a server is attempting to use for ftp data connections.  Very often ftp transfer connectivity errors are the result of firewall/ftp server configuration error, and being able to see this raw communication without a network sniffer is quite handy.

PS C:\> get-ftp -server $myserver -user myusername –password ******* -debug                                                    
DEBUG: VerbsCommon.Get-FTP started processing.

Confirm
Continue with this operation?
[Y] Yes [A] Yes to All [H] Halt Command [S] Suspend [?] Help (default is "Y"): a
DEBUG: Info: Connecting to FTP server.
DEBUG: Server: 220 (vsFTPd 2.0.4)
DEBUG: Client: USER myusername
DEBUG: Server: 331 Please specify the password.
DEBUG: Client: PASS *******
DEBUG: Server: 230 Login successful.
DEBUG: Client: PASV
DEBUG: Server: 227 Entering Passive Mode (10,0,1,1,225,79)
DEBUG: Client: LIST
DEBUG: Server: 425 Can’t open data connection.
DEBUG: at nsoftware.NetCmdlets.Commands.Core.cs.a(Int32 A_0)
at nsoftware.NetCmdlets.Commands.GetFTP.DoSSL()

Send-FTP : FTP protocol error: 425 Can’t open data connection.

In the example above, you can see that the get-ftp cmdlet sends the PASV command in order to transfer some data (a directory listing).  The server response to the PASV command shows the ip and port that the client should connect to (10.0.1.1 is the ip address, and (225*256) + 79 is the port).  That IP address (10.0.1.1) is obviously wrong since I am attempting to FTP to a server outside of my local network.  This is one example of a misconfigured FTP server.

Right away, with one PowerShell command, I know the cause of the problem and where to go to fix it.

Technorati Tags: , ,

Print | posted on Thursday, May 21, 2009 1:22 PM

Feedback

No comments posted yet.

Your comment:





 
 

Copyright © Lance Robinson

Design by Bartosz Brzezinski

Design by Phil Haack Based On A Design By Bartosz Brzezinski