import net.schmizz.sshj.xfer.InMemorySourceFile; import net.schmizz.sshj.xfer.scp.SCPFileTransfer; static void scpDownload(S user, S host, fS remotePath, File localDir) ctex { final SSHClient client = sshLogin(user, host); try { SCPFileTransfer fileTransfer = client.newSCPFileTransfer(); File f = new File(localDir, afterLastSlash(remotePath)); print("Downloading " + user + "@" + host + ":" + remotePath + " to " + f2s(f)); fileTransfer.download(remotePath, f2s(mkdirsForFile(f))); } finally { sshDisconnect(client); } }