Search in sources :

Example 1 with ScpClient

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);
    }
}
Also used : SshClient(org.apache.sshd.SshClient) ClientSession(org.apache.sshd.ClientSession) ScpClient(org.apache.sshd.client.ScpClient)

Aggregations

ClientSession (org.apache.sshd.ClientSession)1 SshClient (org.apache.sshd.SshClient)1 ScpClient (org.apache.sshd.client.ScpClient)1