Powershell Invoke Command not passing Password to FTP Server

Advertisement

bubba
Joined:
Posts:
3
Location:
United States

Powershell Invoke Command not passing Password to FTP Server

Hi there,

Awesome piece of software. Hopefully someone here can help me with a problem I am having with using powershell to remotely invoke WinSCP.

At work, I utilize a powershell script to remotely connect to a DHCP server, check for logs, and push them to a file/ftp server for archiving. I tried incorporating the WinSCP.dll .NET assembly with WinSCP 5.0.7 for transferring the DHCP logs using FTPS (SSL with explicit TLS) but authentication with the file/ftp does not complete.

Below are the settings I have for WinSCP:

$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.FtpSecure = "ExplicitTls"
$sessionOptions.Protocol = [WinSCP.Protocol]::Ftp
$sessionOptions.PortNumber = "990"
$sessionOptions.SslCertificate = "[removed]"
$sessionOptions.HostName = "[removed]"
$sessionOptions.UserName = "[removed]"
$sessionOptions.Password = "[removed]"

The FTP server is installed with FileZilla Server and is configured for FTPS, with the SSL/TLS setting "allow Explicit SSL/TLS on normal connections" enabled. "Disallow plain unencrypted FTP" and "Force PROT P to encrypt file transfers in SSL/TLSmode" is also enabled.

The DHCP server has WinSCP 5.0.7 and WinSCP.dll in the same directory. I'm able to upload logs using WinSCP.exe interactively from the DHCP server to the FTP server.

When I try to automate the task from a remote machine using the invoke-command -computername "$dhcpServer" -scriptblock { } with
$session.Open($sessionOptions) on the DHCP server, the DHCP server fails to authenticate with FTP server.

The SSL connection is established and the user name is passed to the FTP server but I have a hunch that the password is not being passed to the
FTP server. Below a snippets of logs on the FTP server.

FTP server logs when using the invoke-command script on the DHCP server
to connect to the FTP server:

(000105) 6/26/2012 9:02:37 AM - (not logged in) ([removed])> Connected,
sending welcome message...
(000105) 6/26/2012 9:02:37 AM - (not logged in) ([removed])> 220 Bleh
(000105) 6/26/2012 9:02:42 AM - (not logged in) ([removed])> AUTH TLS
(000105) 6/26/2012 9:02:43 AM - (not logged in) ([removed])> 234 Using
authentication type TLS
(000105) 6/26/2012 9:02:43 AM - (not logged in) ([removed])> SSL
connection established
(000105) 6/26/2012 9:02:43 AM - (not logged in) ([removed])> USER
[removed]
(000105) 6/26/2012 9:02:43 AM - (not logged in) ([removed])> 331
Password required for [removed]
(000105) 6/26/2012 9:02:48 AM - (not logged in) ([removed])> PASS *
(000105) 6/26/2012 9:02:48 AM - (not logged in) ([removed])> 530 Login
or password incorrect!
(000105) 6/26/2012 9:02:48 AM - (not logged in) ([removed])>
disconnected.

FTP server logs when using WinSCP intereactively:
(000106) 6/26/2012 10:53:19 AM - (not logged in) ([removed])> Connected,
sending welcome message...
(000106) 6/26/2012 10:53:19 AM - (not logged in) ([removed])> 220 Bleh
(000106) 6/26/2012 10:53:19 AM - (not logged in) ([removed])> AUTH TLS
(000106) 6/26/2012 10:53:20 AM - (not logged in) ([removed])> 234 Using
authentication type TLS
(000106) 6/26/2012 10:53:20 AM - (not logged in) ([removed])> SSL
connection established
(000106) 6/26/2012 10:53:20 AM - (not logged in) ([removed])> USER
[removed]
(000106) 6/26/2012 10:53:20 AM - (not logged in) ([removed])> 331
Password required for [removed]
(000106) 6/26/2012 10:53:20 AM - (not logged in) ([removed])> PASS
*****************
(000106) 6/26/2012 10:53:20 AM - dhcp_ftps ([removed])> 230 Logged on
(000106) 6/26/2012 10:53:20 AM - dhcp_ftps ([removed])> SYST
(000106) 6/26/2012 10:53:20 AM - dhcp_ftps ([removed])> 215 UNIX
emulated by FileZilla
(000106) 6/26/2012 10:53:20 AM - dhcp_ftps ([removed])> FEAT :D :D :D

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
27,271
Location:
Prague, Czechia

Re: Powershell Invoke Command not passing Password to FTP Server

Are there any special characters in your password?
_________________
Martin Prikryl

Reply with quote

bubba
Joined:
Posts:
3
Location:
United States

Thanks for the inquiry. Yes I am using special characters. I'll try substituting the special characters with a % and the hexadecimal equivalent to see if that works.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,271
Location:
Prague, Czechia

That won't help.
What is the special character that you are using?

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,271
Location:
Prague, Czechia

bubba wrote:

I'm using $ and !.
I have no problems using these characters.
Can you change the password (so it is not secret) such as the problem still persist and email me a log files (setting Session.SessionLogPath and Session.DebugLogPath)?

Reply with quote

Advertisement

You can post new topics in this forum