title: Getting SSH host key from WinSCP .NET assembly connection
body: <p>I am building a SFTP based application using WinSCP .NET assembly.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Before making a connection you either need to set:</p>
  
  <pre><code>ConnectionOption.SshHostKeyFingerprint= SSHkeyString
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>ConnectionOptions.GiveUpSecurityAndAcceptAnySshHostKey = True
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>MessageBox.Show(ConnectionOption.SshHostKeyFingerprint)
  </code></pre>
  
  <p>but that returns an empty result.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>So my question is<br>
  How to I retrieve an unknown SSH key from a connected server using WinSCP .NET assembly?<br>
  OR<br>
  Is there another -freely available- library that enables me to retrieve said SSH key?</p>