java中用Ganymed实现SCP 和SFTP文件传输
博客分类:
JavaTomcatApacheWeb
备忘。
下载jar包:ganymed-ssh2-build210.jar
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.SCPClient;
import ch.ethz.ssh2.SFTPv3Client;
import ch.ethz.ssh2.Session;
import ch.ethz.ssh2.StreamGobbler;
public class Scp {
public static void main(String[] args)
{
String user = "root";
String pass = "******";
String host = "hostip";
Connection con = new Connection(host);
try {
con.connect();
boolean isAuthed = con.authenticateWithPassword(user, pass); System.out.println("isAuthed===="+isAuthed);
SCPClient scpClient = con.createSCPClient();
scpClient.put("localFiles", "remoteDirectory"); //从本地复制文件到远程目录
scpClient.get("remoteFiles","localDirectory"); //从远程获取文件
scpClient.put("D:\\apache-tomcat-6.0.29\\webapps\\recursor\\WEB-INF\\serverfile\\192.168.2.190\\policy\\strategy-baddomain.conf", "/root/testor"); //从本地复制文件到远程目录
Ganymed SSH-2 for Java是用纯Java实现SSH-2协议...脚本文件所在的绝对路径,或者通过cd导航到脚本文件... import ch.ethz.ssh2.SCPClient; import ch.ethz...
与早期的仅支持文件传输的 SCP 协议(SSH1.x 中的)相比,SFTP 协议支持更广泛...NTP/SNTP ftp4j ftp4j 是实现了全功能 FTP 客户端的 Java 类库(LGPL license)...
详解AIX 平台上文件传输方式_IT/计算机_专业资料。...做了安全方面的改进,产生了 SFTP,但是貌似使用 情况...WGET 可实现递归下载,RSYNC 具备 高效率的传输及...
详解AIX 平台上文件传输方式_IT/计算机_专业资料。...做了安全方面的改进,产生了 SFTP,但是貌似使用 情况...WGET 可实现递归下载,RSYNC 具备 高效率的传输及...
热门文档