Post a reply

Options
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)

Options

Topic review

maheller08

Re: GUI and WinSCP.com work, Powershell does not

martin 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.
martin

Re: GUI and WinSCP.com work, Powershell does not

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'
maheller08

Re: GUI and WinSCP.com work, Powershell does not

maheller08 wrote:

martin 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 https://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.
maheller08

Re: GUI and WinSCP.com work, Powershell does not

martin 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 https://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
martin

Re: GUI and WinSCP.com work, Powershell does not

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 https://winscp.net/eng/docs/rawsettings
maheller08

GUI and WinSCP.com work, Powershell does not

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