Key exchange was not finished, connection is closed.解决办法

错误


利用java连接Linux服务器中碰到错误:Key exchange was not finished, connection is closed.,导致服务器的连接失败,报错如下
Key exchange was not finished, connection is closed.解决办法_第1张图片

原因


ssh中的key交换算法不兼容导致

解决办法


修改配置文件

vi /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,[email protected]

重启服务

service sshd restart

你可能感兴趣的:(Java,linux,ssh,服务器)