pom文件:
<dependency>
<groupId>ch.ethz.ganymed</groupId>
<artifactId>ganymed-ssh2</artifactId>
<version>261</version>
</dependency>
连接远程服务器:
package com.heiheihaxi.jszxdemo2.utils;
import ch.ethz.ssh2.Connection;
public class SCPClientUtil {
private static Connection conn=null;
public static Connection getConnection(){
String hostname="xxx.xxx.xxx.xxx";// ip地址
String username="xxxx";// 用户名
String password="xxxx";// 密码
int port=22;// 端口
conn = new Connection(hostname, port);
try {
// 连接到主机
conn.connect();
// 使用用户名和密码校验
boolean isconn = conn.authenticateWithPassword(username, password);
if (!isconn) {