0 votes
by (180 points)

I am using Rebex for SFTP Connectivity. With the older version of Rebex(2.0.4086.0) sftp connectivity had no issue and worked in one sever. Updated the same to another similar server.In that we got the exception "Getting "Key exchange failed. Requested service is not implemented." when connecting to SFTP.

We added higher version of Rebex dlls in that server and it worked .

But the doubt is with older version of Rebex, sftp connectivity worked in one server and not in the other server. Same SFTP Server(version-7.6)is being used in both application servers when queried there and the platform in Linux Red Hat Platform)

Code used to connect to SFTP

private void ConnectSftp(ref Sftp objSFTP)
{
try
{
SftpConnectionState IsActive = null;
string[] sSFTPHost = ConfigurationSettings.AppSettings["SFTPHost"].Split('|');

            if (objSFTP == null)
            {
                objSFTP = new Sftp();
            }


            IsActive = objSFTP.GetConnectionState();

            if (IsActive.Connected == false)
            {
                objSFTP.Connect(sSFTPHost[0], int.Parse(sSFTPHost[1]));
                objSFTP.Login(sSFTPHost[2], sSFTPHost[3]);
            }
            try
            {
                SetSFTPStatus("C", 2);
            }
            catch { }
        }
        catch (Exception ex)
        {
            objSFTP.Disconnect();

            Common.WriteLogService("Error while connecting SFTP: " + ex.Message,ex.StackTrace,true);
            try
            {
                SetSFTPStatus("E", 2);
            }
            catch { }
        }
    }
Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)

Rebex SFTP 2.0.4086.0 is more than 8 years old and is no longer compatible with some third-party implementations because these have changed a lot in those 8 years as well.

This particular error is known to be reported by some SSH servers when the SSH client uses a legacy variant of Diffie-Hellman key exchange. Please see this answer for details and some background information (that explains the behavior you observed).

Upgrading to a recent version of Rebex SFTP is the recommended solution. And for scenarios where even the recent version doesn't work out-of-the-box, Sftp object offers Settings.SshParameters.UseLegacyGroupExchange that makes it possible to enable or disable legacy group exchange explicitly.

...