【发布时间】:2016-03-21 15:11:45
【问题描述】:
我正在使用 ssh 工具与学校服务器建立 ssh 连接,该示例我正在使用来自源的示例来建立 ssh 连接。我的问题是我不想要任何用户输入提示但是弹出一个提示说主机的真实性无法建立,用户需要按是继续,我如何编码它让程序接受提示自己。
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");
【问题讨论】: