error in generated c# code (mistake between Password and PrivateKeyPassphrase)

Advertisement

kwenix
Guest

error in generated c# code (mistake between Password and PrivateKeyPassphrase)

I was able to connect using WinSCP, so I copied c# code into project which would fail because of authentication issues ?!

When researching logs and doc I found mistake in generated c# code:

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "blablalab.com",
PortNumber = 22,
UserName = "whatever",
Password = "complicatedpassword",
SshHostKeyFingerprint = "dont care",
SshPrivateKeyPath = @"C:\temp\my_private_key.ppk",
};

should have been

SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "blablalab.com",
PortNumber = 22,
UserName = "whatever",
PrivateKeyPassphrase = "complicatedpassword",
SshHostKeyFingerprint = "dont care",
SshPrivateKeyPath = @"C:\temp\my_private_key.ppk",
};

After correcting, c# code now runs fine...
Now you just need to correct in WinSCP for future usage !?

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

WinSCP will never really generates PrivateKeyPassphrase property, as a key passphrase is not part of stored session settings. It's always prompted for during authentication only.
If Password property was generated, then it's most probably because you entered a key passphrase as a password on WinSCP login dialog. But password is never (code nor GUI) used to decrypt a key.
If my conclusions are wrong, please let me know.

Reply with quote

Guest

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

martin wrote:

WinSCP will never really generates PrivateKeyPassphrase property, as a key passphrase is not part of stored session settings. It's always prompted for during authentication only.
If Password property was generated, then it's most probably because you entered a key passphrase as a password on WinSCP login dialog. But password is never (code nor GUI) used to decrypt a key.
If my conclusions are wrong, please let me know.
well... I did not invent this...
I entered the PrivateKeyPassphrase property in WINSCP GUI to test connection using GUI.
Once this worked I clicked the generate code option.
What I got is what I explained.
So I invite you to test this scenario for yourself: running v 5.13.4.8731 here.

Reply with quote

Guest

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

Anonymous wrote:

martin wrote:

WinSCP will never really generates PrivateKeyPassphrase property, as a key passphrase is not part of stored session settings. It's always prompted for during authentication only.
If Password property was generated, then it's most probably because you entered a key passphrase as a password on WinSCP login dialog. But password is never (code nor GUI) used to decrypt a key.
If my conclusions are wrong, please let me know.
well... I did not invent this...
I entered the PrivateKeyPassphrase property in WINSCP GUI to test connection using GUI.
Once this worked I clicked the generate code option.
What I got is what I explained.
So I invite you to test this scenario for yourself: running v 5.13.4.8731 here.
as a side note: the generated code contained the CORRECT passphrase value, but referred to the WRONG session parameter.

Reply with quote

martin
Site Admin
martin avatar

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

How did you "entered the PrivateKeyPassphrase property in WINSCP GUI to test connection using GUI"?

Reply with quote

Advertisement

Guest

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

martin wrote:

How did you "entered the PrivateKeyPassphrase property in WINSCP GUI to test connection using GUI"?
during connection phase in GUI, a progess window is displayed.
Once authentication is addressed, the progress stops and I'm invited to enter passphrase in a popup.
ps this SFTP connection requires username and private key, no password is used.

[img][/img]

Description: screenshot login window

Capture.PNG

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,440
Location:
Prague, Czechia

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, enable logging, log in to your server and do the operation and only the operation that causes the error. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Reply with quote

Guest

Re: error in generated c# code (mistake between Password and PrivateKeyPassphrase)

martin wrote:

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, enable logging, log in to your server and do the operation and only the operation that causes the error. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

See attached file
  • Prod.log (33.7 KB, Private file)
Description: debug 2 level log attached; usernames, servernames, .. have been edited for privacy reasons

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum