Topic "FTP proxy - Command PWD not accepted during connected"

Author Message
Jamie

Guest


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: (Smile [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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26138
Location: Prague, Czechia
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 https://stackoverflow.com/q/3626109/850848#43272165
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License