5
我使用ssh工具來建立到學校服務器的ssh連接,我使用的是一個來自ssh連接源的例子。我的問題是我不想要任何用戶輸入提示,但是彈出一個提示說主機的真實性無法建立,用戶需要按yes才能繼續,我該如何編寫程序以接受提示本身。UserInfo通過是點擊功能
Session session = jsch.getSession(user, host, 22);
//username and host I can input directly into program so thats not a problem
// username and password will be given via UserInfo interface.
UserInfo ui = new MyUserInfo();
//this is the part that uses the UserInfo, which pulls up a prompt
//how can I code the prompt to automatically choose yes?
session.setUserInfo(ui);
session.setPassword("password");
session.connect();
String command = JOptionPane.showInputDialog("Enter command", "set|grep SSH");
工作謝謝你的幫助。 – user541597 2011-04-06 05:48:29
@ user541597最受歡迎 – Yaneeve 2011-04-06 05:50:56
@Yaneeve此程序不會擺脫用戶提示。運行你的代碼時,我可以看到用戶仍然需要點擊輸入。請確認您已經將此代碼說明可以完成此操作來連接遠程服務器,但它無助於自動執行身份驗證過程。 – MKod 2017-11-14 13:06:07