java控制scp传输文件

来源:互联网 发布:jquery post 数组参数 编辑:程序博客网 时间:2024/06/02 02:48

需要导入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();        }    }}

原创粉丝点击