java代码连接Linux服务器时,报错“There was a problem while connecting to XX.XX.XX.XX
Caused by: java.io.IOException: Key exchange was not finished, connection is closed.”的解决方案。
【解决方案】
(1)在/etc/ssh/sshd_config文件最后一行加上(文字不换行):
KexAlgorithms 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
(2)重启sshd服务
systemctl restart sshd.service