Posts

Showing posts from April, 2017

SFTP file Transfer using JSch

Image
JSch(Java Secure Channel) is a Java implementation of SSH2, which allows you to connect to a sshd server and perform various operations like File Transfer, Port forwarding, etc. JSch is distributed under BSD License and you could get the jar from their official website or SourceForge. JSch is also available in the Central Maven Repository. Here’s how you could use JSch for file transfers on SSH2. Below are the four steps that you need to transfer files: Authentication Connection Set Path Transfer First we need to create a session with an authentication either by password or SSH keys. JSch jsch = new JSch(); Session session = jsch.getSession(CredentialsManager.getUser(),                 CredentialsManager.getHost(), CredentialsManager.getPort()); session.setPassword(CredentialsManager.getPassword()); java.util.Properties config = new java.util.Properties();        config.put("StrictHostKeyChecking"...