Search in sources :

Example 1 with PromiscuousVerifier

use of net.schmizz.sshj.transport.verification.PromiscuousVerifier in project vcell by virtualcell.

the class SimDataConnection method createSSHClient.

private static SSHClient createSSHClient(String host, String user, String password) throws Exception {
    SSHClient sshClient = null;
    try {
        sshClient = new SSHClient();
        // !!! only use the PromiscuousVerifier if the VMs you are connecting to are known and trusted !!!
        sshClient.addHostKeyVerifier(new PromiscuousVerifier());
        sshClient.connect(host);
        sshClient.authPassword(user, password);
        return sshClient;
    } catch (Exception e) {
        if (sshClient != null) {
            try {
                sshClient.disconnect();
            } catch (Exception e2) {
                e.printStackTrace();
            }
        }
        throw e;
    }
}
Also used : PromiscuousVerifier(net.schmizz.sshj.transport.verification.PromiscuousVerifier) SSHClient(net.schmizz.sshj.SSHClient)

Aggregations

SSHClient (net.schmizz.sshj.SSHClient)1 PromiscuousVerifier (net.schmizz.sshj.transport.verification.PromiscuousVerifier)1