My user would need to validate his Private Key against his Git Repository . It is similar to "Test Connection" button in any DB Client tool.
I am using JSCH to do this validation in Java (i just need to connect using SSH and tell that connection is successful). Below is my Java code
public class SSHConnect {
private String file = "c:\\me\\ssh-keys\\config_31_jan";
public static void main(String... args) {
new SSHConnect().invoke();
}
public void invoke () {
JSch jSch = new JSch();
try {
jSch.addIdentity(file);
Session session = jSch.getSession("MY_USER_NAME","github.my_company.com",22) ;
session.connect();
} catch (JSchException e) {
e.printStackTrace();
}
}
}
I get the below exception while doing so
com.jcraft.jsch.JSchException: UnknownHostKey: github.***.com. RSA key fingerprint is 6e:23:f4:4a:49:fd:18:77:ce:35:3e:ae:7c:a9:f6:ed
at com.jcraft.jsch.Session.checkHost(Session.java:805)
at com.jcraft.jsch.Session.connect(Session.java:345)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.pcfdev.main.SSHConnect.invoke(SSHConnect.java:23)
at com.pcfdev.main.SSHConnect.main(SSHConnect.java:13)
Am i missing to do anything ? Please help