Java SSH Ganymed - 尝试使用用户名和密码连接时出现随机错误

标签 java ssh

我们正在使用该库通过 ssh 使用用户名和密码进行连接。有时,connection.authenticateWithPassword 方法返回 false(收到消息:SSH_MSG_USERAUTH_FAILURE),而其他方法可以正常返回 true。 用户名和密码在所有情况下都是正确的。

目前尝试连接的方法有很多:publickey、gssapi-keyex、gssapi-with-mic 和密码。其中存在password方法,实际上,connection.isAuthMethodAvailable(this.username, "password")方法返回true。

我们已经添加了库日志记录,但到目前为止我们还没有发现任何错误。

有什么想法可以帮助我们吗?

private Connection createConnection() throws IOException, InterruptedException {

        logger.debug("Creating ssh connection...");

        Connection connection = new Connection(this.ip, this.port);
        connection.setTCPNoDelay(this.tcpNoDelay);
        connection.connect(null, this.connectTimeout, this.kexTimeout);     

        if(connection.isAuthMethodAvailable(this.username, "password")) {
            if(!connection.authenticateWithPassword(this.username, this.password)) {
                logger.debug("Authentication failed!");
                connection.close();
                throw new IOException("Authentification failed");
            }
        } else {
            logger.debug("Authentication password method is not available!!");
        }

        logger.debug("Connection was created successfull!");
        return connection;
    }

最佳答案

您能否提供有关成功和失败的更多详细信息。不清楚在单个设备上成功和失败是否是随机的,或者您成功地对一台设备进行了身份验证,但在另一台设备上却失败了?

如果针对特定设备始终失败,那么该设备会报告哪些身份验证选项?

关于Java SSH Ganymed - 尝试使用用户名和密码连接时出现随机错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55690098/

相关文章:

java - 如何在多个java类中自动修改代码?

python - 创建命令 Python 的输出

ruby - 无法通过SSH运行Chef-solo命令

Git:团队如何从测试服务器 pull 和推送到存储库

java - 我可以使用 ssh 运行 java jar 程序吗?

linux - Tee 命令 unix

java - 如何从没有 id 的 html 中读取元素?

java - jpql 比较字符串作为 int

java - IntelliJ 和 JSP/JSTL 无法解析 tomcat7 中 JSTL 的标签库

java - 如何加快第一个唯一字符查找