I use visual studio 2017(Windows 10 OS) windows form assign Renci.SshNet as a reference. I add a button to call new SshClient with IP, account, password.
private void button1_Click(object senderMy, EventArgs eMy)
{
byte[] expectedFingerPrint = new byte[] {
0x66, 0x31, 0xaf, 0x00, 0x54, 0xb9, 0x87, 0x31,
0xff, 0x58, 0x1c, 0x31, 0xb1, 0xa2, 0x4c, 0x6b
};
using (var client = new SshClient("192.168.x.x", "x", "x"))
{
client.HostKeyReceived += (sender, e) =>
{
if (expectedFingerPrint.Length == e.FingerPrint.Length)
{
for (var i = 0; i < expectedFingerPrint.Length; i++)
{
if (expectedFingerPrint[i] != e.FingerPrint[i])
{
e.CanTrust = false;
break;
}
}
}
else
{
e.CanTrust = false;
}
};
client.Connect();
}
}
But when I click the button and then Unhandled Exception window appears. The error message as below:
Renci.SshNet.Common.SshConnectionException: 'Key exchange negotiation failed.'
Does somebody know how to solve this problem?
private ISession CreateAndConnectSession()
{
var session = _serviceFactory.CreateSession(ConnectionInfo);
session.HostKeyReceived += Session_HostKeyReceived;
session.ErrorOccured += Session_ErrorOccured;
try
{
session.Connect();
return session;
}
catch
{
DisposeSession(session);
throw;//<=======Renci.SshNet.Common.SshConnectionException: 'Key exchange negotiation failed.'
}
}
I use visual studio 2017(Windows 10 OS) windows form assign Renci.SshNet as a reference. I add a button to call new SshClient with IP, account, password.
But when I click the button and then Unhandled Exception window appears. The error message as below:
Renci.SshNet.Common.SshConnectionException: 'Key exchange negotiation failed.'
Does somebody know how to solve this problem?