Search code examples
sshj2ssh

ssh connection fails with j2ssh giving TransportProtocolException


I'm using j2ssh-core-0.2.9.jar to ssh to a Host.

In the logs I can see :

Client Algorithms: [diffie-hellman-group1-sha1]

Server Algorithms: [curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group-
exchange-sha256, diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1]

I read the documentation provided on :

https://www.openssh.com/legacy.html

I went to the host to which I'm trying to ssh and executed :

ssh -Q kex

The output is :

diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
diffie-hellman-group1-sha1
curve25519-sha256@libssh.org

I'm not able to understand how i can resolve this issue, because even though in the logs i can see that the server's key exchange methods do not contain diffie-hellman-group1-sha1 but when i execute the ssh-Q kex command on the host, the output shows that diffie-hellman-group1-sha1 is present.

Please help.


Solution

  • Your SSH client, which is now roughly 10 years old does not support the stronger, more secure algorithms of more modern servers.

    I recommend (as the author of the API you are using) that you stop using it and move to a different API. There are plenty more up-to-date open source Java SSH APIs available to you including my own J2SSH Maverick, JSch and I'm sure there will be comments providing the case for others.