需要导入ganymed-ssh2-build210.jar
import ch.ethz.ssh2.Connection; import ch.ethz.ssh2.SCPClient; import java.io.IOException; /** * Created by Administrator on 2017/6/29. */ public class testScp { public static void main(String[] args){ //创建连接 Connection con = new Connection("132.97.153.51", 22); try { con.connect(); //服务器账号密码 boolean isAuthed = con.authenticateWithPassword("root","123456Qw"); //创建连接 SCPClient scpClient = con.createSCPClient(); //远程获取文件到本地 scpClient.get("/home/testScp0629", "E:/"); } catch (IOException e) { e.printStackTrace(); } } }