I am building a SFTP based application using WinSCP .NET assembly.
One 'key' thing that I seem to be missing is that there doesn't appear to be a way for the application to validate the host it's connected to using the SSH-Key unless the user is able to provide it.
As we know this isn't normally the case and I would like to still use the SSH key without the user using a 3rd party program to acquire it.
Before making a connection you either need to set:
ConnectionOption.SshHostKeyFingerprint= SSHkeyString
OR
ConnectionOptions.GiveUpSecurityAndAcceptAnySshHostKey = True
and if you don't know what the key is yet you have no choice to do the latter, and I assume you would be able to get the property of the SSH host key by calling this after the connection is made:
MessageBox.Show(ConnectionOption.SshHostKeyFingerprint)
but that returns an empty result.
I've looked over the documentation for the .NET connector and there doesn't seem a way to retrieve the SSH-Key of the server you're connected to.
It appears there are some other libraries that appear to have this feature, but the ones I found are commercially licensed. I suppose even a regular SSH connector (no ftp) with that ability would work -just to get the SSH key - if I could find one.
So my question is
How to I retrieve an unknown SSH key from a connected server using WinSCP .NET assembly?
OR
Is there another -freely available- library that enables me to retrieve said SSH key?