Search in sources :

Example 1 with ToSshjHostKeyVerifierAdapter

use of com.jn.agileway.ssh.client.impl.sshj.verifier.ToSshjHostKeyVerifierAdapter in project agileway by fangjinuo.

the class SshjConnection method connect.

@Override
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SshException {
    try {
        makeSureSshClient();
        if (!sshClient.isConnected()) {
            if (!this.hostKeyVerifier.isEmpty()) {
                sshClient.addHostKeyVerifier(new ToSshjHostKeyVerifierAdapter(this.hostKeyVerifier));
            }
            if (localAddr == null || !Nets.isValidPort(localPort)) {
                sshClient.connect(host, port);
            } else {
                sshClient.connect(host, port, localAddr, localPort);
            }
        }
        setStatus(SshConnectionStatus.CONNECTED);
    } catch (Throwable ex) {
        throw new SshException(ex);
    }
}
Also used : SshException(com.jn.agileway.ssh.client.SshException) ToSshjHostKeyVerifierAdapter(com.jn.agileway.ssh.client.impl.sshj.verifier.ToSshjHostKeyVerifierAdapter)

Aggregations

SshException (com.jn.agileway.ssh.client.SshException)1 ToSshjHostKeyVerifierAdapter (com.jn.agileway.ssh.client.impl.sshj.verifier.ToSshjHostKeyVerifierAdapter)1