using a combination of JSCH and Apache VFS Commons to SFTP with a private key
package test.sftp;
import java.io.File;
import org.apache.commons.vfs.AllFileSelector;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.FileSystemOptions;
import org.apache.commons.vfs.VFS;
import org.apache.commons.vfs.provider.sftp.SftpFileSystemConfigBuilder;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.SftpException;
public class SFTPTest {
public static void main(String[] args) throws JSchException, SftpException,
FileSystemException {
FileSystemOptions options = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(options, "no");
File keyFile = new File("path/to/the/private/key.ppk");
SftpFileSystemConfigBuilder.getInstance().setIdentities(options, new File[] { keyFile });
SftpFileSystemConfigBuilder.getInstance().setKnownHosts(options, new File("path/to/known_hosts")); // optional step, usually ~/.ssh/known_hosts
FileSystemManager fsManager = VFS.getManager();
String uri = "sftp://username:password@hostname:22";
FileObject from = fsManager.resolveFile(uri, options);
FileObject to = fsManager.resolveFile("/tmp", options);
to.copyFrom(from, new AllFileSelector());
}
}
Your view on binary differs from the vast majority of websites I go through,
I’m pleased.
I benefit from your suggestions on options, you own a specific view that
i am not used to. Superb.
Let’s feature a conversation some time around
binary options trading along with what we can do to ensure it is more effective for everybody.
Let’s feature a conversation some time with regards to options
trading and what we’ll be able to do to ensure that it
is more effective for everybody.
Your look at binary differs from almost all of
the blog posts I go through, I’m satisfied.
Your approach to binary options trading differs from
the majority of the websites I read, I’m impressed.