What is the best method of performing an scp transfer via the Java programming language? It seems I may be able to perform this via JSSE, JSch or the bouncy castle java libr
-: Refining Fernando's answer a little, if you use Maven for dependency management :-
pom.xml:
org.apache.ant
ant-jsch
${ant-jsch.version}
Add this dependency in your project. Latest version can be found here.
Java code:
public void scpUpload(String source, String destination) {
Scp scp = new Scp();
scp.setPort(port);
scp.setLocalFile(source);
scp.setTodir(username + ":" + password + "@" + host + ":" + destination);
scp.setProject(new Project());
scp.setTrust(true);
scp.execute();
}