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博客