Hello, Martin, thank you for the follow-up on all topics.
This may need a new topic, but the site is telling me in read-only mode (so adding here).
I have connections to sites using non-blank passphrases and .ssh public and private keys. I'm successful via the WinSCP GUI, and via the building a running script, and winscp.com
Is it still an issue with the .Net Assembly, to do this?
I've read your threads about two-phase authentication...
Via the GUI, the log shows:
. 2019-02-12 11:23:47.734 Reading key file "<PATH>\id_rsa.ppk"
! 2019-02-12 11:23:47.736 Using username "XXXXXXX".
. 2019-02-12 11:23:47.758 Waiting for the server to continue with the initialization
. 2019-02-12 11:23:47.758 Looking for incoming data
. 2019-02-12 11:23:47.758 Looking for network events
. 2019-02-12 11:23:47.873 Detected network event
. 2019-02-12 11:23:47.873 Enumerating network events for socket 2276
. 2019-02-12 11:23:47.873 Enumerated 1 network events making 1 cumulative events for socket 2276
. 2019-02-12 11:23:47.873 Handling network read event on socket 2276 with error 0
. 2019-02-12 11:23:47.873 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2019-02-12 11:23:47.873 Offered public key
. 2019-02-12 11:23:47.874 Waiting for the server to continue with the initialization
. 2019-02-12 11:23:47.874 Looking for incoming data
. 2019-02-12 11:23:47.874 Looking for network events
. 2019-02-12 11:23:47.939 Detected network event
. 2019-02-12 11:23:47.939 Enumerating network events for socket 2276
. 2019-02-12 11:23:47.939 Enumerated 1 network events making 1 cumulative events for socket 2276
. 2019-02-12 11:23:47.939 Handling network read event on socket 2276 with error 0
. 2019-02-12 11:23:47.939 Offer of public key accepted
! 2019-02-12 11:23:47.939 Authenticating with public key "<KEY>"
. 2019-02-12 11:23:47.964 Prompt (passphrase, "SSH key passphrase", <no instructions>, "Passphrase for key "<KEY>": ")
. 2019-02-12 11:23:48.039 Session upkeep
. 2019-02-12 11:23:48.039 Looking for network events
. 2019-02-12 11:23:48.039 Timeout waiting for network events
. 2019-02-12 11:23:48.493 Session upkeep
. 2019-02-12 11:23:48.493 Looking for network events
. 2019-02-12 11:23:48.493 Timeout waiting for network events
. 2019-02-12 11:23:48.996 Session upkeep
. 2019-02-12 11:23:48.996 Looking for network events
. 2019-02-12 11:23:48.996 Timeout waiting for network events
. 2019-02-12 11:23:49.494 Session upkeep
. 2019-02-12 11:23:49.495 Looking for network events
. 2019-02-12 11:23:49.495 Timeout waiting for network events
. 2019-02-12 11:23:49.996 Session upkeep
. 2019-02-12 11:23:49.997 Looking for network events
. 2019-02-12 11:23:49.997 Timeout waiting for network events
. 2019-02-12 11:23:50.492 Session upkeep
. 2019-02-12 11:23:50.493 Looking for network events
. 2019-02-12 11:23:50.493 Timeout waiting for network events
. 2019-02-12 11:23:50.992 Session upkeep
. 2019-02-12 11:23:50.994 Looking for network events
. 2019-02-12 11:23:50.994 Timeout waiting for network events
. 2019-02-12 11:23:51.493 Session upkeep
. 2019-02-12 11:23:51.494 Looking for network events
. 2019-02-12 11:23:51.494 Timeout waiting for network events
. 2019-02-12 11:23:51.680 Sent public key signature
. 2019-02-12 11:23:51.680 Waiting for the server to continue with the initialization
. 2019-02-12 11:23:51.680 Looking for incoming data
. 2019-02-12 11:23:51.680 Looking for network events
. 2019-02-12 11:23:51.746 Detected network event
. 2019-02-12 11:23:51.746 Enumerating network events for socket 2276
. 2019-02-12 11:23:51.746 Enumerated 1 network events making 1 cumulative events for socket 2276
. 2019-02-12 11:23:51.746 Handling network read event on socket 2276 with error 0
. 2019-02-12 11:23:51.746 Access granted
In the .Net code, I set these variables (PowerShell or Perl):
PowerShell here:
# Load WinSCP .NET assembly
Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = "<SITE.SFTP.COM>"
UserName = "XXXXXXX"
SshPrivateKeyPath = "<PATH>\id_rsa.ppk"
PrivateKeyPassphrase = "<MY_KEY_HERE>"
SshHostKeyFingerprint = "<SSH KEY Fingerprint>"
}
$session = New-Object WinSCP.Session
$session.SessionLogPath = "C:\temp\winscp.log"
LOG FROM This (winscp.log) fails immediately, rejecting the key attempt:
. 2019-02-12 11:29:22.599 Reading key file "<PATH>\id_rsa.ppk"
! 2019-02-12 11:29:22.600 Using username "XXXXXXX".
. 2019-02-12 11:29:22.672 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2019-02-12 11:29:22.672 Offered public key
! 2019-02-12 11:29:22.738 Server refused our key
. 2019-02-12 11:29:22.739 Server refused our key
. 2019-02-12 11:29:22.739 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2019-02-12 11:29:22.739 Attempting keyboard-interactive authentication
. 2019-02-12 11:29:22.804 Server refused keyboard-interactive authentication
. 2019-02-12 11:29:22.804 Server offered these authentication methods: publickey,password,keyboard-interactive
. 2019-02-12 11:29:22.804 Prompt (password, "SSH password", <no instructions>, "&Password: ")
. 2019-02-12 11:29:22.805 Disconnected: Unable to authenticate
What am I doing wrong? (or is this just not possible?)
- Joe P.