【发布时间】:2019-04-15 13:18:29
【问题描述】:
我们正在使用该库通过用户名和密码通过 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;
}
【问题讨论】: