File Transfer using SFTP in Java (JSch)

This article shows how to do file transfer from a remote server to the local system and vice versa, using SSH File Transfer Protocol (SFTP) in Java. P.S Tested with JSch 0.1.55 1. JSch Dependency pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> 2. File Transfer – JSch Examples 2.1 In JSch, we can use put and …

Read more

JSch – invalid privatekey exception

This Java example tries to use JSch to transfer a file from the local folder to a remote server using public and private keys, instead of a password. pom.xml <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.55</version> </dependency> SFTPFileTransfer.java package com.mkyong.io.howto; import com.jcraft.jsch.*; public class SFTPFileTransfer { private static final String REMOTE_HOST = "1.1.1.1"; private static final String USERNAME …

Read more