FTP proxy - Command PWD not accepted during connected

Advertisement

Jamie
Guest

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 ftp.targetsite.com -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!

Jamie

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: FTP proxy - Command PWD not accepted during connected

It's probably the "USER %proxyuser, USER %user@%host" FTP proxy type.
Try to setup the connection in WinSCP GUI.
See https://winscp.net/eng/docs/ui_login_proxy

Once you get it working, have the GUI generate a code template for you.
https://winscp.net/eng/docs/ui_generateurl#code

See also the second part of my answer at:
Is it possible to use C# FtpWebRequest through a FTP proxy?

Reply with quote

Advertisement

You can post new topics in this forum