用户信息传递“是”点击即可运行
我正在使用 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");
I am using ssh tools to make a ssh connection to a school server, the example I am using an example from the source that makes an ssh connection. My problem is I don't want any user input prompts however a prompt pops up saying the authenticity of host can't be established and the user needs to press yes to continue, how can I code it for the program to accept the prompt by itself.
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");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们使用下面的代码:
最重要的是:
We use the code below:
and most importantly: