use of org.apache.sshd.client.ScpClient in project alien4cloud by alien4cloud.
the class SSHUtil method doWithScp.
private static void doWithScp(String user, String ip, int port, String pemPath, DoWithScpAction doWithScpAction) throws IOException, InterruptedException {
SshClient client = SshClient.setUpDefaultClient();
ClientSession session = null;
try {
client.start();
session = connect(client, user, loadKeyPair(pemPath), ip, port);
ScpClient scpClient = session.createScpClient();
doWithScpAction.doScpAction(scpClient);
} finally {
if (session != null) {
session.close(true);
}
client.close(true);
}
}
Aggregations