Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


FTP proxy - Command PWD not accepted during connected

Hi All,

Looking for some help.

I'm working at a client who has a particular form of FTP proxy.
Basically, when connecting from an internal resource to an external FTP site, the network forwards the connection to an internal 'ftp proxy' server. The initial connection must be authenticated using internal credentials, after which, the user of the connection needs to reauthenticate (USER ftpsiteuser , PASS ftpsitepass) to the target FTP site.

I have never seen this type of security mechanism before, and not quite sure how to handle it.

While attempting to script this with the .NET library from WinSCP, I get the following error following the initial connection (and initial authentication with the internal user/pass):

New-WinSCPSession : Exception calling "Open" with "1" argument(s): "Error getting name of current remote directory.
Command PWD not accepted during Connected"
At line:9 char:15
+ ... tpsession = New-WinSCPSession -HostName -Credential (Get- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-WinSCPSession], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException,New-WinSCPSession

It seems that by default, the library is connecting and sending PWD. This causes the New-WinSCPSession cmdlet to fail, and not create the FTP session.
-ErrorAction Continue , does not help either.
I've also tried adding: -RawSetting @{PostLoginCommands=""}
That did not help either.

Looking for help - perhaps this is a form of proxy that I can use the built in functionality to pass through? (if so, I am not aware of the type or what form of proxy this is called, as I have never encountered it before)
Or perhaps there is a way to 'mute' or 'disable' the PWD on connect command?

This is a roadblock for automating some transfers, and asking for a bypass on this is simply not possible - I must be able to deal with the proxy.
I tried the WinSCP library/module because I saw that I could Invoke ftp commands, and effectively authenticate a 2nd time as is needed in my case. My real issue is the PWD after the initial connection, as between initial authentication, and secondary authentication, there are no commands other than USER and PASS accepted.

Any advice would be greatly appreciated.

Thanks in advance!