jsch.setConfigRepository(defaultJSch.getConfigRepository()); jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository()); jsch.addIdentity(identityKey); byIdentityFile.put(identityKey, jsch);
/** @param trySshAgent disable this if your ssh agent is configured, but you don't want to use it. */ public static JSch jsch(boolean trySshAgent) throws IOException { JSch jsch; jsch = new JSch(); if (trySshAgent) { if (SshAgentSocket.isConfigured()) { try { SshAgent.configure(jsch); } catch (NoClassDefFoundError e) { // ok -- we have no ssh-agent dependencies } catch (Throwable e) { System.out.println("TODO: " + trySshAgent); e.printStackTrace(); } } else { // don't try to connect to agent - it throws an exception if the environment variable is not defined } } jsch.setHostKeyRepository(new AcceptAllHostKeyRepository()); return jsch; }
/** * 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. */ public SshConnection(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()); } catch (JSchException ex) { throw new SshException(ex); } }
jsch = new JSch(); configureJSch(jsch); jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository()); jsch.addIdentity(identityKey); byIdentityFile.put(identityKey, jsch);
this.jsch.setHostKeyRepository(hostKeyRepository); } else { if (StringUtils.isNullOrEmpty(this.trustedServerSSLCerfiticateFile)) { addPublicKeyToHostKeyRepostitory(trustStore.getCertificate("cert").getPublicKey(), hostKeyRepository); this.jsch.setHostKeyRepository(hostKeyRepository); } catch (Exception e) { throw new Exception("Unable to add public key from certificate '"
/** * 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); } }
auth.getPrivateKeyFilePassword().getBytes("UTF-8")); client.setHostKeyRepository(new BlindHostKeyRepository()); connectSession = client.getSession(auth.getUsername(), host, port); connectSession.setConfig("PreferredAuthentications", "publickey");
jsch.setHostKeyRepository(new EasyRepo()); if (this.passphrase == null) { jsch.addIdentity(file.getAbsolutePath());
jsch.setHostKeyRepository(new EasyRepo()); if (this.passphrase == null) { jsch.addIdentity(file.getAbsolutePath());
jsch.setConfigRepository(defaultJSch.getConfigRepository()); jsch.setHostKeyRepository(defaultJSch.getHostKeyRepository()); jsch.addIdentity(identityKey); byIdentityFile.put(identityKey, jsch);
jsch.setHostKeyRepository(hostKeyRepository);
client.setHostKeyRepository(new HostKeyRepositoryBridge(client.getHostKeyRepository())); session = client.getSession(username, hostname, port); final SocketFactory socketFactory = getConfiguration().getSocketFactory();