我正在尝试从客户端计算机连接 sftp 服务器。但是 com.jcraft.jsch.JSchException:算法协商失败了我遇到的这种错误。
com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:540)
at com.jcraft.jsch.Session.connect(Session.java:288)
at com.jcraft.jsch.Session.connect(Session.java:145)
at com.na.common.NewReading.main(NewReading.java:28)
Run Code Online (Sandbox Code Playgroud)
我试图通过在 Jenkins 中使用算法协商失败 SSH来解决这个问题,并且我已经更改了 sshd_config 中的 KexAlgorithms,但出现错误。
所以请帮助我。谢谢
在我的情况下 - 服务器上的 OpenSSH_6.7p1 - 我不得不修改 KexAlgorithms 和 MACs(额外的 hmac-md5、hmac-sha1、hmac-sha1-96、hmac-md5-96 值):
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com,hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96
Run Code Online (Sandbox Code Playgroud)
上面应该放:
/etc/ssh/sshd_config
Run Code Online (Sandbox Code Playgroud)
然后重启ssh:
sudo /etc/init.d/ssh restart
Run Code Online (Sandbox Code Playgroud)