0 votes
by (180 points)

I am trying to connect to SFTP with Private Key Authentication
On reaching client.Connect code area itself I am getting the exception "Key Exchange Failed. Requested Service not Implemented". I am using Rebex DLLs got of late(Rebex.Net.proxySocket,Rebex.Net.Sftp,Rebex.Net.SSH,Rebex.Security)
Below is the code sample
var client = new Sftp();
client.Connect(txtHost.Text, Convert.ToInt32(txtPort.Text));

SshPrivateKey privateKey = new SshPrivateKey(txtPvtKeyPath.Text, txtPvtKeyPwd.Text);

// log in

client.Login(txtUserName.Text, txtPassword.Text, privateKey);

Detailed Exception:
Error in SFTP Private Key Authentication-Exception:Key exchange failed. Requested service is not implemented.
Inner Exception:Rebex.Net.SshException: Key exchange failed. Requested service is not implemented. ---> Rebex.Net.SshException: Requested service is not implemented.
at Rebex.Net.SshSession.cqLugQ(Byte[] , Int32 , Int32 )
at Rebex.Net.SshSession.cDtmAOZ(cMbfbTZ , Object[] )
at Rebex.Net.SshSession.CFLiXJ(ANiLIV )
at wWGvS.CLJmsVZ.ArwjUr(SshSession , Byte[] , Byte[] , Byte[] , Byte[] , Byte[]& , Byte[]& , Byte[]& )
at Rebex.Net.SshSession.ArwjUr(Byte[] )
--- End of inner exception stack trace ---
at Rebex.Net.SshSession.ArwjUr(Byte[] )
at Rebex.Net.SshSession.Negotiate()
at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters)
Stack Trace at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort, SshParameters parameters)
at AECBSFTPAuthenticationTool.AECBSFTPAuth.btnConnectClick(Object sender, EventArgs e) in

1 Answer

0 votes
by (144k points)

Your version of Rebex SFTP is more than 10 years old. It is no longer compatible with lot of contemporary third-party SFTP/SSH implementations because these have changed a lot in those 10 (or more) years.

This particular (and somewhat misleading) error is known to be reported by some SSH servers when the SSH client uses a legacy variant of Diffie-Hellman key exchange that used to be prevalent in early 2000s. Please see this answer for additional details.

Upgrading to a recent version of Rebex SFTP suitable for contemporary servers would resolve the issue. (And for very rare 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.)

...