これと同様の質問が他にもありますが、私の答えにはならないと思います。Java サーブレットから、会社のネットワーク上の任意のサーバーに SSH で接続し、この不明なキーの例外を動的に処理してから、サーバーの現在のステータスを取得して表示するコマンドを発行できる必要があります。
JSch session.setFingerprint を使用するという提案を 1 つ見ましたが、私が知る限り存在しないため、変更されたか何かに違いありません。私はネットビーンズを使用しています。
これが私のコードです:
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
String url = "validurl";
String user = "validuser";
String password = "validpassword";
printer.println ("HelloWorld!");
JSch ssh = new JSch();
ChannelShell ch = null;
Session session = null;
try {
session = ssh.getSession(user, "serverIP", 22);
session.setPassword(password);
session.connect();
ch = (ChannelShell)session.openChannel("shell");
ch.connect();
}
catch (JSchException e) {
System.out.println ("Exception: " + e);
}
catch (Exception e) {
System.out.println ("Exception: " + e);
}
ありがとう!デヴィン