问题描述
说明:
尝试将请求发送到尝试访问Netopeer2服务器的应用程序,但是出现问题并且密钥交换失败。有一些解决方案,如何在/etc/ssh/sshd_config
的服务器端进行配置,但是我们希望它在应用程序中的客户端。
该应用程序使用Apache MINA SSHD建立连接(GitHub)。默认情况下,某些算法是禁用的。我们希望在下面的该Main类中使它们能够与服务器交换rsa-sha2-512,rsa-sha2-256
。关于如何使用Apache MINA SSHD做到这一点的任何想法?
完整的错误消息为:
java.lang.IllegalStateException: Unable to negotiate key exchange for server host key algorithms
(client: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-rsa,ssh-dss /
server: rsa-sha2-512,rsa-sha2-256)
引发错误的代码:
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.session.ClientSession;
import java.io.IOException;
public class Main{
public static void main(String[] args) {
SshClient client = SshClient.setUpDefaultClient();
client.start();
try {
ClientSession session = client.connect("root","172.17.0.2",830).verify(10000).getSession();
session.addPasswordIdentity("root");
session.auth().verify(9999);
// error 'Unable to negotiate key exchange for server host key algorithms' is thrown
}
catch (IOException e){
e.printStackTrace();
}
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)