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

kulicny

RE:

Thank you.
kulicny

RE:

Correct. That is exactly what it was doing and that was the character in question. Therefore it was only sending a partial passphrase value.
martin

Re: RE:

Do you mean that PowerShell interpreted some special character (dollar sign possibly?) in your double-quoted string?
kulicny

RE:

Well, you were right. There was a special character in the passphrase. I didn't realize that it would interpret the character as special while setting SessionOptions. Enclosing the PrivateKeyPassphrase in single quotes vs double quotes solved it and it passes the entire string. Thanks for the suggestion and apologies for not having considered that sooner.
martin

Re: logs

I believe you are either using a different key or a different passphrase. It's hard to imagine any other explanation.

Are there any special characters in your passphrase? Did you test it with some very trivial one ("abc")?

Enable password logging in both GUI and .NET, to check if WinSCP really gets the passphrase that it should.
kulicny

logs

Here are the requested logs. Let me know if you need anything else.
martin

Re: SessionOptions passphrase

Please post complete log of successful session from GUI and failing session from PowerShell.
kulicny

update

It appears to have something to do with Pageant. I did a bit more research, and after adding the private key and passphrase to Pageant, it executes as expected. I wouldn't have expected to have to have Pageant running and the ppk in there to make this to work. Plus, I still had to supply the passphrase in the script, so I'm not sure this is the "correct" solution. But it did connect and put the file.
kulicny

SessionOptions passphrase

I am scripting in PowerShell. I send the following commands using SessionOptions and keep getting the results below from the log file. I've successfully connected with the WinSCP client app using the PPK and the passphrase. I just can't get it to work via the PowerShell script. I'm not sure what I'm missing or should be doing differently.
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "<my host name>"
        UserName = "<myusername>"
        PrivateKeyPassphrase = "<mypassphrase>"
        SshPrivateKeyPath = "<pathformyPPK>"
        SshHostKeyFingerprint = "<ssh rsa fingerprint>"
}

This is the from the log file:
Reading key file "<pathformyPPK>"

Using username "<myusername>".
Script: Using username "<myusername>".
Server offered these authentication methods: publickey
Offered public key
Offer of public key accepted
Authenticating with public key "<mypublickey>"
Script: Authenticating with public key "<mypublickey>".
Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "<mypublickey>": ")
Using configured passphrase.
Wrong passphrase
Script: Wrong passphrase.