1

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 :

alt text

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.

3 Answers 3

3
   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);
}
Sign up to request clarification or add additional context in comments.

Comments

1

You have to understand why this message pops up.

SSH is a secure service, meaning that the identity of the client and the identity of the server are guaranteed. To guarantee that you actually reached the server you want to reach (for how it is possible that you connect to the wrong server without your knowledge, google "DNS cache poisoning"), the client displays the recieved server name and fingerprint. These values identify the server. You are supposed to look if this is in fact the fingerprint you generated on the server by comparing the fingerprint through a secure channel (via telephone with the server admin, for instance).

Having said that, usual SSH clients save your decision to accept the fingerprint/server name and do not ask again. It seems that your client does not. So you either have the option to change the source code (if it's licensed under an open license) or find a way to automatically press "Yes" whenever this question pops up (this can be achieved with toolkits like Autoit 3 with a very short script).

2 Comments

or find a way to automatically press "Yes" whenever this question pops up (this can be achieved with toolkits like Autoit 3 with a very short script). This is the part I'm interested in, I read everything else in your post thats why I'm asking for an answer I don't know how to do that
Using a software like "Autoit 3", you can automate windows tasks like running or closing applications, pressing buttons, moving the mouse and so on. It is programmed using a very simple scripting language that can be grasped in 10 minutes. Check it out at autoitscript.com/autoit3/index.shtml.
0

check out http://sourceforge.net/projects/sshtools/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.