文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > java中用Ganymed实现SCP 和SFTP文件传输
侵权投诉

java中用Ganymed实现SCP 和SFTP文件传输

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"); //从本地复制文件到远程目录

第1页

你可能喜欢

热门文档

相关文档

  • Java通过SSH2协议执行远程Shell脚本(ganymed-ssh2-buil...

    Ganymed SSH-2 for Java是用纯Java实现SSH-2协议...脚本文件所在的绝对路径,或者通过cd导航到脚本文件... import ch.ethz.ssh2.SCPClient; import ch.ethz...

  • FTP、FTPS和SFTP

    与早期的仅支持文件传输的 SCP 协议(SSH1.x 中的)相比,SFTP 协议支持更广泛...NTP/SNTP ftp4j ftp4j 是实现了全功能 FTP 客户端的 Java 类库(LGPL license)...

  • 详解AIX 平台上文件传输方式

    详解AIX 平台上文件传输方式_IT/计算机_专业资料。...做了安全方面的改进,产生了 SFTP,但是貌似使用 情况...WGET 可实现递归下载,RSYNC 具备 高效率的传输及...

  • 详解AIX 平台上文件传输方式

    详解AIX 平台上文件传输方式_IT/计算机_专业资料。...做了安全方面的改进,产生了 SFTP,但是貌似使用 情况...WGET 可实现递归下载,RSYNC 具备 高效率的传输及...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email