jschSession.setServerAliveInterval(this.serverAliveInterval);
private static void configureSessionServerAliveInterval(Map<String, String> config, Session session) throws JSchException { String serverAliveInterval = config.get(SSH_CONFIG_SERVER_ALIVE_INTERVAL); if (serverAliveInterval != null) { try { session.setServerAliveInterval(Integer.parseInt(serverAliveInterval) * 1000); } catch (NumberFormatException e) { e.printStackTrace(); } } }
private Session getRemoteSession(String userName, String password, String dnsName, int sshPort) throws JSchException { LOGGER.log(Level.INFO, "AzureVMAgentSSHLauncher: getRemoteSession: getting remote session for user {0} to host {1}:{2}", new Object[]{userName, dnsName, sshPort}); JSch remoteClient = new JSch(); try { final Session session = remoteClient.getSession(userName, dnsName, sshPort); session.setConfig("StrictHostKeyChecking", "no"); session.setPassword(password); // pinging server for every 1 minutes to keep the connection alive final int serverAliveIntervalInMillis = 60 * 1000; session.setServerAliveInterval(serverAliveIntervalInMillis); session.connect(); LOGGER.log(Level.INFO, "AzureVMAgentSSHLauncher: getRemoteSession: Got remote session for user {0} to host {1}:{2}", new Object[]{userName, dnsName, sshPort}); return session; } catch (JSchException e) { LOGGER.log(Level.SEVERE, String.format("AzureVMAgentSSHLauncher: getRemoteSession: " + "Got exception while connecting to remote host %s:%s", dnsName, sshPort), e); throw e; } }
public void openConnection(int keepAliveInMili) throws IOException { try { session = jsch.getSession(username, hostname, port); session.setServerAliveInterval(keepAliveInMili); } catch (JSchException e) { throw new IOException(String.format("Could not getSession for %s", hostname), e); } Properties config = new Properties(); config.put("StrictHostKeyChecking", "no"); //config.put("PreferredAuthentications", "password"); session.setConfig(config); session.setPassword(password); try { session.connect(); } catch (JSchException e) { throw new IOException(String.format("Could not connect session for %s", hostname), e); } }
config.put("StrictHostKeyChecking", "no"); session.setServerAliveInterval(10000); session.setConfig(config); session.connect(0);
private Session createSession(final PrintStream logger) throws JSchException, IOException, InterruptedException { final StandardUsernameCredentials user = lookupCredentialsById(credentialId); if (user == null) { String message = "Credentials with id '" + credentialId + "', no longer exist!"; logger.println(message); throw new InterruptedException(message); } final JSchConnector connector = new JSchConnector(user.getUsername(), getResolvedHostname(), port); final SSHAuthenticator<JSchConnector, StandardUsernameCredentials> authenticator = SSHAuthenticator .newInstance(connector, user); authenticator.authenticate(new StreamTaskListener(logger, Charset.defaultCharset())); final Session session = connector.getSession(); session.setServerAliveInterval(serverAliveInterval); final Properties config = new Properties(); //TODO put this as configuration option instead of ignoring by default config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(timeout); return session; }
session.setServerAliveInterval((int) TimeUnit.SECONDS.toMillis(30));
/** * Creates and opens a SshConnection. * * @param host the host to connect to. * @param port the port. * @param authentication the authentication-info * @throws SshException if something happens - usually due to bad config. * @throws IOException if the unfortunate happens. */ protected SshConnectionImpl(String host, int port, Authentication authentication) throws SshException, IOException { logger.debug("connecting..."); try { client = new JSch(); client.addIdentity(authentication.getPrivateKeyFile().getAbsolutePath(), authentication.getPrivateKeyFilePassword()); client.setHostKeyRepository(new BlindHostKeyRepository()); connectSession = client.getSession(authentication.getUsername(), host, port); connectSession.connect(); logger.debug("Connected: {}", connectSession.isConnected()); connectSession.setServerAliveInterval(ALIVE_INTERVAL); } catch (JSchException ex) { throw new SshException(ex); } }
session.setServerAliveInterval(keepAliveInterval);
session.setServerAliveInterval(SERVER_ALIVE_INTERVAL); session.connect(SESSION_TIMEOUT);
connectSession.setServerAliveInterval(ALIVE_INTERVAL); } catch (JSchException ex) { throw new SshException(ex);
jschSession.setServerAliveInterval(this.serverAliveInterval);
this.getLogin(), this.getAddr(), this.getPort() ); session.setServerAliveInterval( (int) TimeUnit.SECONDS.toMillis(Tv.TEN) );
this.getLogin(), this.getAddr(), this.getPort() ); session.setServerAliveInterval( (int) TimeUnit.SECONDS.toMillis(Tv.TEN) );
); session.setPassword(this.password); session.setServerAliveInterval( (int) TimeUnit.SECONDS.toMillis(Tv.TEN) );
); session.setPassword(this.password); session.setServerAliveInterval( (int) TimeUnit.SECONDS.toMillis(Tv.TEN) );
session.setDaemonThread(true); session.setTimeout(timeout); session.setServerAliveInterval(keepalive); session.setConfig("StrictHostKeyChecking", strictHostKeyChecking ? "yes" : "no");
session.setServerAliveInterval(getServerAliveIntervalSeconds() * 1000);
session = jsch.getSession(profile.getUser(), profile.getHost(), profile.getPort()); session.setConfig("StrictHostKeyChecking", "no"); session.setServerAliveInterval((int) TimeUnit.SECONDS.toMillis(10)); session.setTimeout((int) TimeUnit.SECONDS.toMillis(60));
int interval = FileSystemProviderSupport.getIntValue(this, SERVER_ALIVE_INTERVAL); try { session.setServerAliveInterval(interval); } catch (JSchException e) { throw asFileSystemException(e);