List of usage examples for org.apache.commons.vfs2.provider.sftp IdentityInfo IdentityInfo
public IdentityInfo(final File privateKey)
From source file:org.schedoscope.export.ftp.upload.Uploader.java
/** * A constructor to initialize a user name / pub key sftp connection. * * @param user The username to use. * @param keyFile The private key file. * @param passphrase The passphrase to use (can be null) * @param conf The Hadoop Configuration object. * @param passive A flag to use FTP passive mode (only for ftp connections). * @param userIsRoot A flag indicating the user dir is (s)ftp root dir. * @throws IOException Is thrown if an error occurs. */// w ww . ja v a2s. c o m public Uploader(String user, File keyFile, String passphrase, Configuration conf, boolean passive, boolean userIsRoot) throws IOException { initFileSystem(conf, passive, userIsRoot); // set up authentication - pub/priv key LOG.debug("setting up pub key authentication for sftp protocol"); UserAuthenticator auth = new StaticUserAuthenticator(null, user, null); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); IdentityInfo ident = new IdentityInfo(keyFile); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no"); SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, new PassphraseUserInfo(passphrase)); SftpFileSystemConfigBuilder.getInstance().setIdentityInfo(opts, ident); }