Topic "Why is SshHostKeyFingerprint needed when SshPrivateKeyPath is set to private key file"

Author Message
Orionsg

Guest


When I connect manually using the GUI WinSCP client to an SFTP site, I specify Host Name, User Name and Private Key File. No password or fingerprint is needed to connect. However, when I try to connect through the .NET client by specifying the same corresponding properties, I get this error:

"System.ArgumentException: SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set."

Is there a default value set for this property when using the Windows GUI client that I need to set directly when using the .NET client?
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
Orionsg wrote:
When I connect manually using the GUI WinSCP client to an SFTP site, I specify Host Name, User Name and Private Key File. No password or fingerprint is needed to connect.

That's not true. On the first connect, you are prompted to verify a public key of the server.
Orionsg

Guest


martin wrote:
That's not true. On the first connect, you are prompted to verify a public key of the server.


You are absolutely correct Smile.
I did not have to enter anything, but there was a message with the public key.

In the meanwhile I have studied the Session class a bit further and found the ScanFingerprint method to get the public key, including the example. Using this, I was able to get my code to work as expected.

Thanks for your reply and the awesome client!
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
Orionsg wrote:
In the meanwhile I have studied the Session class a bit further and found the ScanFingerprint method to get the public key, including the example. Using this, I was able to get my code to work as expected.

Note that you should use the ScanFingerprint only to implement an interactive prompt to get the public key verified by an user.
You should not use it to automatically accept the key! That does not make you safe. It would be effectively the same as setting the SessionOptions.GiveUpSecurityAndAcceptAnySshHostKey.
Advertisements

You can post new topics in this forum

Search

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