SFTP (SSH File Transfer Protocol)
Par PlaceOweb le dimanche, novembre 20 2011, 13:57 - Outils Internet - Lien permanent
SFTP (SSH File Transfer Protocol), n'est pas FTP exécuté sur SSH, mais plutôt un nouveau protocole conçu dès le départ par le groupe de travail IETF SECSH. Il est parfois confondu avec Simple File Transfer Protocol.
STFP est un protocole de communication fonctionnant au-dessus de SSH à ne pas confondre avec File Transfer Protocol over SSL, abrégé FTPS.
SFTP JAVA
Apache Commons VFS
Commons VFS provides a single API for accessing various different file systems. It presents a uniform view of the files from various different sources, such as the files on local disk, on an HTTP server, or inside a Zip archive.
- Support for numerous file system types
Chilkat
Chilkat Class Libraries for Java, commercially licensed components include: SFTP
Jaramiko
Jaramiko is a port of paramiko for java: a pure-java implementation of the SSH version 2 protocol,
JSch
JSch is a pure Java implementation of SSH2.
jsch javadoc, jsch don't provide documentation (in source, or html), alternativly, there is a documented version of JSch with downloadable or onlive Jsch Javadoc
package com.placeoweb; import java.util.Properties; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelSftp; import com.jcraft.jsch.JSch; import com.jcraft.jsch.Session; public class Sftp { /** * @param args */ public static void main(String[] args) { int port = 22; String username = "root"; String host = "my.host.com"; String pass = "myPassword"; String khfile = "/home/testuser/.ssh/known_hosts"; String identityfile = "/home/testuser/.ssh/id_rsa"; JSch jsch = null; Session session = null; Channel channel = null; ChannelSftp c = null; try { jsch = new JSch(); session = jsch.getSession(username, host, port); session.setPassword(pass); // jsch.setKnownHosts(khfile); // jsch.addIdentity(identityfile); // http://stackoverflow.com/questions/4852016/jcraft-jsch-without-interactive-popup-windows Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); channel = session.openChannel("sftp"); channel.connect(); c = (ChannelSftp) channel; System.out.println("is Connected !"); System.out.println("Starting File Upload:"); String fsrc = "C:\\src.txt", fdest = "/tmp/cde.txt"; c.put(fsrc, fdest); c.get(fdest, "C:\\src.copy.by.upload.and.download.txt"); } catch (Exception e) { e.printStackTrace(); /* Without setKnownHosts et addIdentity => com.jcraft.jsch.JSchException: UnknownHostKey: my.host.com. RSA key fingerprint is 42:28:d5:d4:73:d7:74:3d:62:f5:74:70:16:75:d3:a6 Without setKnownHosts et addIdentity + config "StrictHostKeyChecking", "no" => OK */ } c.disconnect(); session.disconnect(); } }
Sshj
Sshj - SSHv2 library for Java
SSHTools
SSHTools is a suite of Java SSH applications providing a Java SSH API, SSH Terminal, SSH secured VNC client, SFTP client and SSH Daemon.
Zehon File Transfer Pack
Zehon File Transfer Pack for Java.
SFTP – should be only used for SFTP, the SSH file transfer protocol. However, people often shorten Secure FTP into SFTP - this is not correct, because the S in SFTP does not stand for Secure, but for SSH.
Ressources sur SFTP en JAVA
- Java: What is the best way to SFTP a file from a server (JSch, SSHTools, Apache commons-vfs)
SFTP PHP
- Fonctions Shell2 sécurisé
- PECL : ssh2 Provides bindings to the functions of libssh2 which implements the SSH2 protocol.