/** * Create a new remote session for the requested address. * * @param hc * host configuration * @param user * login to authenticate as. * @param host * server name to connect to. * @param port * port number of the SSH daemon (typically 22). * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return new session instance, but otherwise unconfigured. * @throws com.jcraft.jsch.JSchException * the session could not be created. */ protected Session createSession(final OpenSshConfig.Host hc, final String user, final String host, final int port, FS fs) throws JSchException { return getJSch(hc, fs).getSession(user, host, port); }
/** * Create a new remote session for the requested address. * * @param hc * host configuration * @param user * login to authenticate as. * @param host * server name to connect to. * @param port * port number of the SSH daemon (typically 22). * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return new session instance, but otherwise unconfigured. * @throws JSchException * the session could not be created. */ protected Session createSession(final OpenSshConfig.Host hc, final String user, final String host, final int port, FS fs) throws JSchException { return getJSch(hc, fs).getSession(user, host, port); }
/** * Create a new remote session for the requested address. * * @param hc * host configuration * @param user * login to authenticate as. * @param host * server name to connect to. * @param port * port number of the SSH daemon (typically 22). * @param fs * the file system abstraction which will be necessary to * perform certain file system operations. * @return new session instance, but otherwise unconfigured. * @throws com.jcraft.jsch.JSchException * the session could not be created. */ protected Session createSession(final OpenSshConfig.Host hc, final String user, final String host, final int port, FS fs) throws JSchException { return getJSch(hc, fs).getSession(user, host, port); }
session = null; knownHosts(getJSch(hc, fs), fs);
@Override protected JSch getJSch(OpenSshConfig.Host hc, FS fs) throws JSchException { JSch jsch = super.getJSch(hc, fs); if (StringUtils.hasValue(passphrase)) { // If passphrase is set, add it to identity File sshDir = new File(fs.userHome(), ".ssh"); if (sshDir.isDirectory()) { updateIdentity(jsch, new File(sshDir, "identity")); updateIdentity(jsch, new File(sshDir, "id_rsa")); updateIdentity(jsch, new File(sshDir, "id_dsa")); } } return jsch; }
protected com.jcraft.jsch.JSch getJSch(OpenSshConfig.Host hc, FS fs) throws com.jcraft.jsch.JSchException { JSch jsch = super.getJSch(hc, fs); JSch.setConfig("StrictHostKeyChecking", "no"); if(FileSystemManager.exists(privateKeyFile)) { jsch.addIdentity(privateKeyFile); } jsch.setKnownHosts(knownHostsFile); return jsch; }
protected com.jcraft.jsch.JSch getJSch(OpenSshConfig.Host hc, FS fs) throws com.jcraft.jsch.JSchException { JSch jsch = super.getJSch(hc, fs); JSch.setConfig("StrictHostKeyChecking", "no"); if(FileSystemManager.exists(privateKeyFile)) { jsch.addIdentity(privateKeyFile); } else if (FileSystemManager.exists(sshDir + "/id_rsa")) { jsch.addIdentity(sshDir + "/id_rsa"); } jsch.setKnownHosts(knownHostsFile); return jsch; }
session = null; knownHosts(getJSch(hc, fs), fs);
session = null; knownHosts(getJSch(hc, fs), fs);