Topic "GUI and WinSCP.com work, Powershell does not"

Author Message
maheller08
[View user's profile]

Joined: 2013-05-14
Posts: 4
Location: PA
The important part of the Powershell is this. The password has a $ in it. The session log and debug logs are attached and the logs from the GUI when it worked. Any help is greatly appreciated. Please let me know if more information is needed. WinSCP 5.1.4

Get this error from the script. "Connection has been unexpectedly closed. Server sent command exit status 0."

. 2013-05-14 16:09:06.800 Attempting keyboard-interactive authentication
. 2013-05-14 16:09:07.002 Prompt (6, SSH server: Password Authentication, Using keyboard-interactive authentication., xxxxxx's password:)
. 2013-05-14 16:09:07.002 Using stored password.
. 2013-05-14 16:09:08.999 Keyboard-interactive authentication failed
! 2013-05-14 16:09:08.999 Access denied
. 2013-05-14 16:09:08.999 Attempting keyboard-interactive authentication
. 2013-05-14 16:09:09.233 Prompt (6, SSH server: Password Authentication, Using keyboard-interactive authentication., xxxxxxx's password:)
. 2013-05-14 16:09:09.233 Disconnected: Unable to authenticate


try
{
# Load WinSCP .NET assembly
[Reflection.Assembly]::LoadFrom("WinSCP.dll") | Out-Null

# Setup session options

$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "xxxxx"
$sessionOptions.UserName = "xxxxx"
$sessionOptions.Password = "xxxxx"
$sessionOptions.SshHostKeyFingerprint = "ssh-rsa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


$session = New-Object WinSCP.Session
$session.SessionLogPath = "seslog.txt"
$session.DebugLogPath = "deblog.txt"

try
{
# Connect
$session.Open($sessionOptions)

# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Automatic
Logs.zip (9.37 KB) [Download]

Description: (none)

Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I can see one difference. In GUI, you have "keyboard interactive" authentication disabled. As a consequence GUI is using password authentication, while .NET library is using keyboard interactive authentication.

Is it by purpose? I actually do not see, how this could cause your problem, but it's definitely worth trying.

See http://winscp.net/eng/docs/rawsettings
_________________
Martin Prikryl
maheller08
[View user's profile]

Joined: 2013-05-14
Posts: 4
Location: PA
prikryl wrote:
I can see one difference. In GUI, you have "keyboard interactive" authentication disabled. As a consequence GUI is using password authentication, while .NET library is using keyboard interactive authentication.

Is it by purpose? I actually do not see, how this could cause your problem, but it's definitely worth trying.

See http://winscp.net/eng/docs/rawsettings


With the GUI I actually tried it with and without attempt keyboard interactive authentication enabled at it works both ways with the GUI. It appears that the remote server, which is not under my control, is not accepting the password from the Powershell script. I looked for, but could not find a way to disable keyboard interactive authentication with the .Net library. Is there a way to do that?

Thank you for your help.
Mark
maheller08
[View user's profile]

Joined: 2013-05-14
Posts: 4
Location: PA
maheller08 wrote:
prikryl wrote:
I can see one difference. In GUI, you have "keyboard interactive" authentication disabled. As a consequence GUI is using password authentication, while .NET library is using keyboard interactive authentication.

Is it by purpose? I actually do not see, how this could cause your problem, but it's definitely worth trying.

See http://winscp.net/eng/docs/rawsettings


With the GUI I actually tried it with and without attempt keyboard interactive authentication enabled at it works both ways with the GUI. It appears that the remote server, which is not under my control, is not accepting the password from the Powershell script. I looked for, but could not find a way to disable keyboard interactive authentication with the .Net library. Is there a way to do that?

Thank you for your help.
Mark


No matter what raw settings I try for authentication the Powershell script will not authenticate. I resorted to creating a VB application. For what ever reason that works fine. It is a mystery to me.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Ok, I took a look on PowerShell string syntax, to find that dollar sign has special meaning, when inside souble-quotes, so you have to escape it. Are you aware of this?

Possibilities:
- use tick sign to escape it: "aaa`$bbb"
- using single quotes: 'aaa$bbb'
_________________
Martin Prikryl
maheller08
[View user's profile]

Joined: 2013-05-14
Posts: 4
Location: PA
prikryl wrote:
Ok, I took a look on PowerShell string syntax, to find that dollar sign has special meaning, when inside souble-quotes, so you have to escape it. Are you aware of this?

Possibilities:
- use tick sign to escape it: "aaa`$bbb"
- using single quotes: 'aaa$bbb'


I should have recogonized that fact, but it did not sink in. Thank you for the insight. The script now works great.

Thank you very much.
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