0 votes
by (140 points)

We are getting the following error consistently while connecting to a remote sftp server.

Rebex.Sftp
Message: Negotiation failed. The server key was rejected by the client.

It is interfering with our ability to download files.
Can you help us troubleshoot what this error means, how severe it is, and how to best handle this exception?

We are able to connect to the same sftp server using third party tools like WinScp/FIleZilla using the same settings.

We are also able to use the same code base on a development machine without issue.

We are also able to use the code base (both locally in development and in production) to connect to a different sftp server without issue.

In all of our connections we use a username/password, so we are confused as to which key the error message is referring.

Best,
Gianluca

Applies to: Rebex SFTP
by (140 points)
we are using the latest version

1 Answer

0 votes
by (144k points)

The "The server key was rejected by the client" error message indicates that the key was rejected by a custom event handler for Sftp.FingerprintCheck event. So it looks like the key is actually being rejected by your application's code. Please check FingerprintCheck handlers in your application to determine why the key is getting rejected.

Also, to rule out an issue in Rebex SFTP itself, try connecting to the server without validating the server key using code like this:

var sftp = new Sftp();
// replace with your server address and port
sftp.Connect("test.rebex.net", 22);

Does this succeed, or does it fail as well?

...