gpt4 book ai didi

java - 使用 ganymed-ssh2 >> 出现错误 "Authentication method password not supported by the server at this stage"

转载 作者:行者123 更新时间:2023-12-01 13:47:54 24 4
gpt4 key购买 nike

我正在使用 ganymed-ssh2 远程执行 xml 配置文件中提供的命令。它适用于大多数服务器,除了一些我收到以下错误的服务器。

java.io.IOException: Password authentication failed. at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:300) at ch.ethz.ssh2.Connection.authenticateWithPassword(Connection.java:309) at GenericAccessOnly.GenericAccessOnly.Access(GenericAccessOnly.java:260) at GenericAccessOnly.GenericAccessOnly.main(GenericAccessOnly.java:190) Caused by: java.io.IOException: Authentication method password not supported by the server at this stage. at ch.ethz.ssh2.auth.AuthenticationManager.authenticatePassword(AuthenticationManager.java:270) ... 3 more

在这方面的任何帮助肯定会有很大帮助。

问候

最佳答案

嗯..异常本身就说明了一切,不是吗?有问题的服务器根本不支持密码身份验证。您应该实现尝试 ganymed-ssh2 支持的不同身份验证方法的代码。

ganymed-ssh2 中包含示例代码,解释了如何检查可用的身份验证方法。示例:

if (connection.isAuthMethodAvailable(getUsername(), "publickey")) {
System.out.println("--> public key auth method supported by server");
} else {
System.out.println("--> public key auth method not supported by server");
}
if (connection.isAuthMethodAvailable(getUsername(), "keyboard-interactive")) {
System.out.println("--> keyboard interactive auth method supported by server");
} else {
System.out.println("--> keyboard interactive auth method not supported by server");
}
if (connection.isAuthMethodAvailable(getUsername(), "password")) {
System.out.println("--> password auth method supported by server");
} else {
System.out.println("--> password auth method not supported by server");
}

这里是examples 。看看SwingShell它不仅仅使用密码身份验证。

关于java - 使用 ganymed-ssh2 >> 出现错误 "Authentication method password not supported by the server at this stage",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20209916/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com