use of com.jn.agileway.ssh.client.impl.j2ssh.verifier.KnownHostsVerifier in project agileway by fangjinuo.
the class J2sshConnectionFactory method setKnownHosts0.
protected void setKnownHosts0(SshConnection connection, J2sshConnectionConfig sshConfig) {
String filepath = sshConfig.getKnownHostsPath();
List<File> files = SshConfigs.getKnownHostsFiles(filepath);
HostKeyVerification verifier = null;
if (files.isEmpty()) {
verifier = new IgnoreHostKeyVerification();
} else {
try {
verifier = new KnownHostsVerifier(files.get(0).getAbsolutePath());
} catch (Throwable ex) {
throw new SshException(ex);
}
}
connection.addHostKeyVerifier(new FromJ2ssHostKeyVerifier(verifier));
}
Aggregations