ssh 连接失败,j2ssh 给出 TransportProtocolException

ssh connection fails with j2ssh giving TransportProtocolException

我正在使用 j2ssh-core-0.2。9.jar 通过 ssh 连接到主机。

在日志中我可以看到:

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]

我阅读了 :

上提供的文档

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

我去了我试图连接到的主机并执行了:

ssh -Q kex

输出为:

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

我无法理解如何解决这个问题,因为即使在日志中我可以看到服务器的密钥交换方法不包含 diffie-hellman-group1-sha1 但是当我执行 ssh -Q kex 命令在主机上,输出显示 diffie-hellman-group1-sha1 存在。

请帮忙。

您的 SSH 客户端,现在大约有 10 年的历史,不支持更现代服务器的更强大、更安全的算法。

我建议(作为您正在使用的 API 的作者)您停止使用它并转移到另一个 API。有更多最新的开源 Java SSH API 可供您使用,包括我自己的 J2SSH Maverick、JSch,我相信会有评论为其他人提供案例。