简体   繁体   English

Java | 小牛SSH | 无法协商传输组件 | sha1 md5 | sha2-512 sha2-256

[英]Java | Maverick SSH | Failed to negotiate a transport Component | sha1 md5 | sha2-512 sha2-256

Key sent by customer working fine using SFTP command via Putty.客户通过 Putty 使用 SFTP 命令正常发送的密钥。 It is working fine through Winscp.它通过 Winscp 工作正常。

But when i try using Java Code then i get following:但是当我尝试使用 Java 代码时,我得到以下信息:

Caused by: com.maverick.ssh.SshException: 
Failed to negotiate a transport component 
  [hmac-sha1,hmac-md5]     [hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512,hmac-sha2-256] 
  [Unknown cause]

Code:代码:

else if (authMethod == AUTH_KEY) {
PublicKeyAuthentication pk = new PublicKeyAuthentication();
SshPrivateKeyFile pkfile = SshPrivateKeyFileFactory.parse(new FileInputStream(pass));

com.maverick.ssh.components.SshKeyPair pair;
if (pkfile.isPassphraseProtected())
   pair = pkfile.toKeyPair(keypass);
else
   pair = pkfile.toKeyPair(null);

pk.setPrivateKey(pair.getPrivateKey());
pk.setPublicKey(pair.getPublicKey());
this.session.authenticate(pk);

The above common code is working fine for existing Keys and not for this new server.上述通用代码适用于现有密钥,但不适用于此新服务器。 Not a concrete solution at code level is found.没有找到代码级别的具体解决方案。

Any thing more to be added here in code or any type of conversions?在代码或任何类型的转换中还有什么要添加的吗?

The problem is that your side is offering only HMAC-MD5 and HMAC-SHA-1 as MAC algorithms, and the server side only supports HMAC-SHA-256 and HMAC-SHA-512.问题是你这边只提供 HMAC-MD5 和 HMAC-SHA-1 作为 MAC 算法,而服务器端只支持 HMAC-SHA-256 和 HMAC-SHA-512。 The server is doing the right thing here, since MD5 and SHA-1 are considered insecure, and even though their HMAC versions aren't insecure when used in SSH, responsible parties have moved away from any use of MD5 and SHA-1.服务器在这里做的是正确的事情,因为 MD5 和 SHA-1 被认为是不安全的,即使它们的 HMAC 版本在 SSH 中使用时不是不安全的,责任方已经不再使用 MD5 和 SHA-1。

Because you and the server can't agree on an algorithm to use, the connection can't continue.因为您和服务器无法就要使用的算法达成一致,所以连接无法继续。

It looks like the latest version of the Maverick SSH client supports the hmac-sha2-256 (HMAC-SHA-256), so you could try upgrading, or you could use a more modern SSH library.看起来最新版本的 Maverick SSH 客户端支持hmac-sha2-256 (HMAC-SHA-256),因此您可以尝试升级,或者您可以使用更现代的 SSH 库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM