I've seen other threads about this error, but I am having this error randomly. Out of 30 connects, 12 got this error. Trying to understand why this is, and what possible solutions are.
using (SftpClient client = new SftpClient(sftpHost, sftpPort, sftpUser, sftpPassword))
{
client.Connect();
}
throws this exception:
Renci.SshNet.Common.SshConnectionException: Server response does not contain SSH protocol identification
No one knows the exact cause for this behavior to be honest.
As a possible fix, Some people suggest creating a counter loop for retrying to connect, suggesting it solved their problem:
int attempts = 0;
do
{
try
{
client.Connect();
}
catch (Renci.SshNet.Common.SshConnectionException e)
{
attempts++;
}
} while (attempts < _connectiontRetryAttempts && !client.IsConnected);
Another suggestion is to add the IP address into the hosts.allow
file on the server, so you could check in that direction as well.
As I said, there is no possible explanation for the behavior altogether.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With