private static ClientSession connectWithRetries(SshClient client, ClientConfig config) throws Exception, InterruptedException {
ClientSession session = null;
int retries = 0;
do {
ConnectFuture future = client.connect(config.getHost(), config.getPort());
future.await();
try {
session = future.getSession();
} catch (RuntimeSshException ex) {
if (retries++ < config.getRetryAttempts()) {
Thread.sleep(config.getRetryDelay() * 1000);