Search in sources :

Example 1 with FromJ2ssHostKeyVerifier

use of com.jn.agileway.ssh.client.impl.j2ssh.verifier.FromJ2ssHostKeyVerifier 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));
}
Also used : IgnoreHostKeyVerification(com.sshtools.j2ssh.transport.IgnoreHostKeyVerification) FromJ2ssHostKeyVerifier(com.jn.agileway.ssh.client.impl.j2ssh.verifier.FromJ2ssHostKeyVerifier) HostKeyVerification(com.sshtools.j2ssh.transport.HostKeyVerification) IgnoreHostKeyVerification(com.sshtools.j2ssh.transport.IgnoreHostKeyVerification) SshException(com.jn.agileway.ssh.client.SshException) File(java.io.File) KnownHostsVerifier(com.jn.agileway.ssh.client.impl.j2ssh.verifier.KnownHostsVerifier)

Aggregations

SshException (com.jn.agileway.ssh.client.SshException)1 FromJ2ssHostKeyVerifier (com.jn.agileway.ssh.client.impl.j2ssh.verifier.FromJ2ssHostKeyVerifier)1 KnownHostsVerifier (com.jn.agileway.ssh.client.impl.j2ssh.verifier.KnownHostsVerifier)1 HostKeyVerification (com.sshtools.j2ssh.transport.HostKeyVerification)1 IgnoreHostKeyVerification (com.sshtools.j2ssh.transport.IgnoreHostKeyVerification)1 File (java.io.File)1