It is working now. I don't see the difference so maybe it was something else I was doing wrong...
public Boolean VerifyConnetion()
{
var passwordAuthMethod = new PasswordAuthenticationMethod(username, password);
var connectionInfo = new ConnectionInfo(host, port, username, passwordAuthMethod);
try
{
client = new ScpClient(connectionInfo);
client.HostKeyReceived += HandleHostKeyReceived; ;
client.Connect();
client.Disconnect();
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}
private void HandleHostKeyReceived(object sender, HostKeyEventArgs ex)
{
if (ex.FingerPrint.SequenceEqual(new byte[] { 0x2a, 0x08, 0xd5, 0x69, 0xe0, 0x9f, 0xcc, 0xdb, 0x3d, 0xc2, 0x78, 0x06, 0x61, 0xd0, 0xf4, 0xc4 })) // TODO
{
ex.CanTrust = true;
}
else
{
ex.CanTrust = false;
}
}