1 导入jar包
jsch-0.1.54.jar
jar包下载地址:
https://sourceforge.net/projects/jsch/files/jsch.jar/0.1.54/jsch-0.1.54.jar/download
如果是maven项目则导入以下依赖:
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
2 实现代码
package cn.cheng.sshlinux;
import java.io.IOException;
import java.util.Properties;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
public class JschOpenHandler {
private static final int DEFAULT_PORT = 80;
private static