Java ssh客户端 [英] Java ssh client
问题描述
我正在尝试创建一个网络应用程序,它将检查多个服务状态,服务器统计信息等。我发现这个
我对swing和java的熟悉程度不是很熟悉。
公共类ManoUserInfo实现UserInfo {
String passwd ;
public void setPassword(String pass){
passwd = pass;
}
@Override
public String getPassphrase(){
return null;
}
public String getPassword(){
return passwd;
}
public boolean promptPassword(String arg0){
return true;
}
public boolean promptPassphrase(String arg0){
return true;
}
//这个方法负责该消息,所以只需让它返回true
public boolean promptYesNo(String arg0){
// Object [] options = {yes ,没有};
/ * int foo = JOptionPane.showOptionDialog(null,
arg0,
警告,
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null ,options,options [0]); * /
返回true;
}
public void showMessage(String message){
JOptionPane.showMessageDialog(null,message);
}
I'm trying to create a web app which will check several service status, server stats etc. I found this http://www.jcraft.com/jsch/ seems to be pretty nice ssh java implementation. But every time I log in in to server I'm prompted to confirm RSA key fingerprint like this :
How can I override this, to always confirm yes without any prompts? I want to remove the whole swing part, I want to make this without any interaction, like this example code I took from the examples available on jscraft.com :
http://www.jcraft.com/jsch/examples/Exec.java
I'm not so familiar with swing and with java in general.
public class ManoUserInfo implements UserInfo {
String passwd;
public void setPassword(String pass) {
passwd = pass;
}
@Override
public String getPassphrase() {
return null;
}
public String getPassword() {
return passwd;
}
public boolean promptPassword(String arg0) {
return true;
}
public boolean promptPassphrase(String arg0) {
return true;
}
//this method responsible for that message, so just make it return true
public boolean promptYesNo(String arg0) {
// Object[] options = {"yes", "no"};
/* int foo = JOptionPane.showOptionDialog(null,
arg0,
"Warning",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null, options, options[0]);*/
return true;
}
public void showMessage(String message) {
JOptionPane.showMessageDialog(null, message);
}
这篇关于Java ssh客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!