0 votes
by (120 points)

I'm receiving the following error message when trying to connect with on of our clients and I can not figure out why. Any ideas on what could be causing this? Thanks.

Rebex.Net.SftpException: Negotiation failed. Disconnected by the server ('The Transport Protocol thread failed:java.lang.NullPointerException'). ---> Rebex.Net.SshException: Disconnected by the server ('The Transport Protocol thread failed:java.lang.NullPointerException').
     at Rebex.Net.SshSession.SON[D,N](FCW`2 D, Int32 N, MCW T, N O, D J, D L)
     at Rebex.Net.SshSession.SON[D,N](FCW`2 D, N N)
     at Rebex.Net.SshSession.TWN(HCW D)
     at Rebex.Net.GCW.A(SshSession D, Byte[] N, Byte[] T, Byte[] O, Byte[] J, JCW& L, Byte[]& A, SshPublicKey& V)
     at Rebex.Net.SshSession.LWN(Byte[] D)
     at Rebex.Net.SshSession.Negotiate()
     at Rebex.Net.Sftp.VFW.LWN(FEW D, Boolean N)
     at Rebex.Net.Sftp.FH(String D, Int32 N, SshParameters T, FEW O)
--- End of inner exception stack trace ---
     at Rebex.Net.Sftp.FH(String D, Int32 N, SshParameters T, FEW O)
     at Rebex.Net.Sftp.GM(String D, Int32 N, SshParameters T)
     at Rebex.Net.Sftp.Connect(String serverName, Int32 serverPort)     
Applies to: Rebex SFTP

1 Answer

0 votes
by (148k points)

The following error message has been reported by the server: "The Transport Protocol thread failed:java.lang.NullPointerException". This means that the most likely cause is a server-side bug.

If you are able to connect to this server using third-party SFTP clients, please try connecting using the latest release of Rebex SFTP with RSA as preferred host key algorithm (to match behavior of third-party clients):

var sftp = new Sftp();
sftp.Settings.SshParameters.PreferredHostKeyAlgorithm = SshHostKeyAlgorithm.RSA;
sftp.LogWriter = new FileLogWriter("rebex-log.txt", LogLevel.Debug);
sftp.Connect(serverName);

If this still fails, please post the log here or mail it to support@rebex.net for analysis.

by (120 points)
I emailed the Log File to Lukas, and ended up adding to my code:
sftp.Settings.SshParameters.KeyExchangeAlgorithms = ~(SshKeyExchangeAlgorithm.DiffieHellmanGroupExchangeSHA1 | SshKeyExchangeAlgorithm.DiffieHellmanGroupExchangeSHA256);

This fixed my issue and I am now able to connect. Thanks for your help!
by (148k points)
Background information: It looks like this server is quite picky about what Diffie-Hellman group exchange requests it accepts. See https://github.com/mscdex/ssh2-streams/issues/85 for what appears to be the same issue with a third-party client SSH library. It might be possible to work around this by using group exchange requests with different sizes, but disabling Diffie-Hellman group exchange ciphers is a suitable workaround as well.
...