public SSHClient close() { try { Utils.close(out); channel.close(false); session.close(false); client.stop(); return this; } finally { this.client = null; this.channel = null; this.session = null; this.out = null; } } }
@Override public void operationComplete(final CloseFuture future) { if (future.isClosed() == false) { session.close(true); } session = null; } });
@Override public void operationComplete(final CloseFuture future) { if (future.isClosed() == false) { session.close(true); } session = null; } });
@Override protected void closeInternal() throws IOException { session.close(true); session = null; client.stop(); client = null; }
public void disconnect() { try { if (logger.isDebugEnabled()) { logger.debug("SSH: disconnecting from [" + toString() + "]"); } clientSession.close(false); } finally { if (sshClient != null) { sshClient.stop(); } } }
session.close(false).addListener(new SshFutureListener<CloseFuture>() { @Override public void operationComplete(final CloseFuture future) {
session.close(false).addListener(new SshFutureListener<CloseFuture>() { @Override public void operationComplete(final CloseFuture future) {
} finally { session.put(Console.IGNORE_INTERRUPTS, oldIgnoreInterrupts); sshSession.close(false);
} finally { session.put(Console.IGNORE_INTERRUPTS, oldIgnoreInterrupts); sshSession.close(false);
private static void doWithScp(String user, String ip, int port, String pemPath, DoWithScpAction doWithScpAction) throws IOException, InterruptedException { SshClient client = SshClient.setUpDefaultClient(); ClientSession session = null; try { client.start(); session = connect(client, user, loadKeyPair(pemPath), ip, port); ScpClient scpClient = session.createScpClient(); doWithScpAction.doScpAction(scpClient); } finally { if (session != null) { session.close(true); } client.close(true); } }