private void initialize() { if (!this.initialized) { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", isStrictHostKeyChecking() ? "yes" : "no"); } }); this.initialized = true; } }
/** * Create a new transport instance without a local repository. * * @param uri the URI used to access the remote repository. This must be the * URI passed to {@link #open(URIish)}. * @since 3.5 */ protected SshTransport(URIish uri) { super(uri); sch = SshSessionFactory.getInstance(); }
/** {@inheritDoc} */ @Override public void close() { if (sock != null) { try { sch.releaseSession(sock); } finally { sock = null; } } } }
public static <T> T useOpenShiftSessionFactory(Callable<T> callable) throws Exception { SshSessionFactory oldFactory = SshSessionFactory.getInstance(); try { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host hc, Session session) { session.setConfig("StrictHostKeyChecking", "no"); } }); return callable.call(); } finally { SshSessionFactory.setInstance(oldFactory); } } }
MessageWriter stderr = new MessageWriter(); try (MessageWriter stdout = new MessageWriter()) { session = SshSessionFactory.getInstance().getSession(sshUri, provider, fs, 1000 * timeout); process = session.exec(command, 0); SshSessionFactory.getInstance().releaseSession(session);
/** * Get the default SSH session * * @return a remote session * @throws org.eclipse.jgit.errors.TransportException * in case of error with opening SSH session */ protected RemoteSession getSession() throws TransportException { if (sock != null) return sock; final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0; final FS fs = local == null ? FS.detect() : local.getFS(); sock = sch .getSession(uri, getCredentialsProvider(), fs, tms); return sock; }
OpenSshConfig(File h, File cfg) { configFile = new OpenSshConfigFile(h, cfg, SshSessionFactory.getLocalUserName()); }
public static void setupSsh(String sshDir) { if(SshSessionFactory.getInstance() == null || !SshSessionFactory.getInstance().getClass().getName().equals(GithubConfigSessionFactory.class.getName())) { log.debug("Setting SSH session factory for ssh dir path {}", sshDir); SshSessionFactory.setInstance(new GithubConfigSessionFactory(sshDir)); } }
MessageWriter stderr = new MessageWriter(); try (MessageWriter stdout = new MessageWriter()) { session = SshSessionFactory.getInstance().getSession(sshUri, provider, fs, 1000 * timeout); process = session.exec(command, 0); SshSessionFactory.getInstance().releaseSession(session);
/** * Get the default SSH session * * @return a remote session * @throws TransportException * in case of error with opening SSH session */ protected RemoteSession getSession() throws TransportException { if (sock != null) return sock; final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0; final FS fs = local == null ? FS.detect() : local.getFS(); sock = sch .getSession(uri, getCredentialsProvider(), fs, tms); return sock; }
OpenSshConfig(File h, File cfg) { configFile = new OpenSshConfigFile(h, cfg, SshSessionFactory.getLocalUserName()); }
@Override public void configure(Transport transport) { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(OpenSshConfig.Host hc, Session session) { session.setConfig("StrictHostKeyChecking", sshUriProperties.isStrictHostKeyChecking() ? "yes" : "no"); } }); } }
/** * Create a new transport instance. * * @param local * the repository this instance will fetch into, or push out of. * This must be the repository passed to * {@link #open(Repository, URIish)}. * @param uri * the URI used to access the remote repository. This must be the * URI passed to {@link #open(Repository, URIish)}. */ protected SshTransport(Repository local, URIish uri) { super(local, uri); sch = SshSessionFactory.getInstance(); }
@Override public void close() { if (sock != null) { try { sch.releaseSession(sock); } finally { sock = null; } } } }
/** * Get the default SSH session * * @return a remote session * @throws org.eclipse.jgit.errors.TransportException * in case of error with opening SSH session */ protected RemoteSession getSession() throws TransportException { if (sock != null) return sock; final int tms = getTimeout() > 0 ? getTimeout() * 1000 : 0; final FS fs = local == null ? FS.detect() : local.getFS(); sock = sch .getSession(uri, getCredentialsProvider(), fs, tms); return sock; }
/** * Initializes SSH authentication */ private void initSSHAuthentication() { SshSessionFactory.setInstance(new CustomJschConfigSessionFactory()); }
/** * Create a new transport instance without a local repository. * * @param uri the URI used to access the remote repository. This must be the * URI passed to {@link #open(URIish)}. * @since 3.5 */ protected SshTransport(URIish uri) { super(uri); sch = SshSessionFactory.getInstance(); }
/** {@inheritDoc} */ @Override public void close() { if (sock != null) { try { sch.releaseSession(sock); } finally { sock = null; } } } }
private void initialize() { if (!this.initialized) { this.basedir = createTempBasedir(); SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", strictHostKeyChecking ? "yes" : "no"); } }); this.initialized = true; } }
/** * Create a new transport instance without a local repository. * * @param uri the URI used to access the remote repository. This must be the * URI passed to {@link #open(URIish)}. * @since 3.5 */ protected SshTransport(URIish uri) { super(uri); sch = SshSessionFactory.getInstance(); }