com.jcraft.jsch.ConfigRepository Java Examples

The following examples show how to use com.jcraft.jsch.ConfigRepository. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SshConfiguration.java    From ssh-proxy with Apache License 2.0 5 votes vote down vote up
public SshConfiguration(ConfigRepository configRepository) throws JSchException {
	JSchHelper.configureGlobalSettings();

	this.configRepository = configRepository;
	jsch.setConfigRepository(this.configRepository);

	Assert.isTrue(Files.isRegularFile(getLocalSshKnownHostsPath()), getLocalSshKnownHostsPath() + " does not exist");
	jsch.setKnownHosts(getLocalSshKnownHostsPath().toString());
}
 
Example #2
Source File: SftpClientFactory.java    From commons-vfs with Apache License 2.0 5 votes vote down vote up
private static void setConfigRepository(final JSch jsch, final File sshDir, final ConfigRepository configRepository, final boolean loadOpenSSHConfig) throws FileSystemException {
    if (configRepository != null) {
        jsch.setConfigRepository(configRepository);
    } else if (loadOpenSSHConfig) {
        try {
            // loading openssh config (~/.ssh/config)
            final ConfigRepository openSSHConfig = OpenSSHConfig.parseFile(new File(sshDir, OPENSSH_CONFIG_NAME).getAbsolutePath());
            jsch.setConfigRepository(openSSHConfig);
        } catch (final IOException e) {
            throw new FileSystemException("vfs.provider.sftp/load-openssh-config.error", e);
        }
    }
}
 
Example #3
Source File: SftpFileSystemConfigBuilder.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the config repository.
 *
 * @param opts The FileSystem options.
 * @return the ConfigRepository
 */
public ConfigRepository getConfigRepository(final FileSystemOptions opts) {
    return (ConfigRepository) this.getParam(opts, CONFIG_REPOSITORY);
}
 
Example #4
Source File: SftpFileSystemConfigBuilder.java    From commons-vfs with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the config repository. e.g. {@code /home/user/.ssh/config}.
 * <p>
 * This is useful when you want to use OpenSSHConfig.
 * </p>
 *
 * @param opts             The FileSystem options.
 * @param configRepository An config repository.
 * @throws FileSystemException if an error occurs.
 * @see <a href="http://www.jcraft.com/jsch/examples/OpenSSHConfig.java.html">OpenSSHConfig</a>
 */
public void setConfigRepository(final FileSystemOptions opts, final ConfigRepository configRepository)
        throws FileSystemException {
    this.setParam(opts, CONFIG_REPOSITORY, configRepository);
}