ssh2遇到的问题:
用密码授权失败
ssh2授权方式对应例如xshell的连接方式
//connection.authenticateWithPassword(username, password);// 认证方式
//先校验密码授权是否通过,其次校验键盘
if (!connection.authenticateWithPassword(username, password)) {
connection.authenticateWithKeyboardInteractive(StringUtils.isNotBlank(username) ? username : "root", (name, instruction, numPrompts, prompt, echo) -> {
String[] result = new String[numPrompts];
for (int i = 0; i < numPrompts; i++) {
result[i] = password;
}
return result;
});
}
参考博客:java远程连接linux并发送命令,两种方案比较Jsch与ganymed-ssh2_MrJson-架构师的博客-CSDN博客