com.jcraft.jsch.JSchException: UnknownHostKey

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-01-05T00:45:31Z Indexed on 2010/04/28 7:33 UTC
Read the original article Hit count: 1276

Filed under:
|
|

I don't know how SSH works and I think that's a simple question. How do I fix that exception:

com.jcraft.jsch.JSchException: UnknownHostKey: mywebsite.com. 
RSA key fingerprint is 22:fb:ee:fe:18:cd:aa:9a:9c:78:89:9f:b4:78:75:b4

I know I should verify that key or something, but there is like zero documentation for Jsch. Here is my code it's really straightforward:

import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;

public class ssh{
  public static void main(String[] arg){

    try{
       JSch jsch = new JSch();

       //create SSH connection
       String host = "mywebsite.com";
       String user = "username";
       String password = "123456";

       Session session = jsch.getSession(user, host, 22);
       session.setPassword(password);
       session.connect();

     }
     catch(Exception e){
       System.out.println(e);
    } 
  }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about ssh