class ChaosSSHClient implements SSHClientWrapper {

    @Override
    public ShellClient connect (int connectionTimeout) throws IOException {
        boolean opened = false;
        Objects.requireNonNull(hostname);
        Objects.requireNonNull(port);
        Objects.requireNonNull(sshCredentials);
        log.debug("Creating connection to {}:{} with {} second timeout", hostname, port, connectionTimeout);
        sshClient = buildNewSSHClient();
        sshClient.addHostKeyVerifier(new PromiscuousVerifier());
        sshClient.setConnectTimeout(connectionTimeout);
        Future<Void> connection = Executors.newSingleThreadExecutor().submit(() -> {
            try {
                sshClient.connect(hostname, port);
                return null;
            } catch (IOException e) {
                throw new ChaosException(SHELL_CLIENT_CONNECT_FAILURE, e);
            }
        });
        try {
            connection.get(connectionTimeout, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new ChaosException(SHELL_CLIENT_CONNECT_FAILURE, e);
        } catch (ExecutionException | TimeoutException e) {
            throw new ChaosException(SHELL_CLIENT_CONNECT_FAILURE, e);
        }
        try {
            log.debug("Connection made, sending authentication");
            sshClient.auth(sshCredentials.getUsername(), sshCredentials.getAuthMethods());
            opened = true;
        } catch (UserAuthException | TransportException e) {
            throw new ChaosException(SHELL_CLIENT_CONNECT_FAILURE, e);
        } finally {
            if (!opened) {
                close();
            }
        }
        return this;
    }

}