@Test public void shouldNotThrowTimeoutOnDisconnect() throws IOException { fixture.getClient().authPassword("u", "u"); Session session = fixture.getClient().startSession(); session.allocateDefaultPTY(); Session.Shell shell = session.startShell(); session.close(); fixture.getClient().disconnect(); } }
checkConnection(); try (Session session = sshClient.startSession(); SessionChannel shell = (SessionChannel) session.startShell(); PrintWriter commandWriter = new PrintWriter(shell.getOutputStream())) { outputHandler.handleStdOut(shell.getInputStream());
session = acquire(newSessionAction()); shell = session.startShell();
session = acquire(newSessionAction()); shell = session.startShell();
private void logIntoIp(String ipAddress) throws IOException, InterruptedException { final SSHClient ssh = new SSHClient(); OpenSSHKeyFile k = new OpenSSHKeyFile(); k.init(new File(dotHaruhi, keyPairName + ".pem")); ssh.addHostKeyVerifier(new PromiscuousVerifier()); ssh.connect(ipAddress); try { ssh.authPublickey(clusterUsername, k); Session that = ssh.startSession(); try { that.allocateDefaultPTY(); Session.Shell shell = that.startShell(); new StreamCopier(shell.getInputStream(), System.out) .bufSize(shell.getLocalMaxPacketSize()) .spawn("stdout"); new StreamCopier(shell.getErrorStream(), System.err) .bufSize(shell.getLocalMaxPacketSize()) .spawn("stderr"); new StreamCopier(System.in, shell.getOutputStream()) .bufSize(shell.getRemoteMaxPacketSize()) .copy(); } finally { that.close(); } } finally { ssh.close(); } }