package util;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;
public class JschTransferlinuxWindows
{
public static void main(String args[])
{
String hostname = "10.10.139.79";
String username = "root";
String password = "*******";
String copyTo;
String copyFrom = "/mnt/fs0/Diff/*";
copyTo = "C:\\Users\\akshay_gawand\\Desktop\\8.3\\Transfer";
JSch jsch = new JSch();
Session session = null;
System.out.println("Trying to connect.....");
try {
session = jsch.getSession(username, hostname, 22);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(password);
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftpChannel = (ChannelSftp) channel;
sftpChannel.get(copyFrom, copyTo);
sftpChannel.exit();
session.disconnect();
} catch (JSchException e) {
e.printStackTrace();
} catch (SftpException e) {
e.printStackTrace();
}
System.out.println("Done !!");
}
}
I am getting below error after executing above code:
Trying to connect.....
com.jcraft.jsch.JSchException: Algorithm negotiation fail
Done !!
at com.jcraft.jsch.Session.receive_kexinit(Session.java:520)
at com.jcraft.jsch.Session.connect(Session.java:286)
at com.jcraft.jsch.Session.connect(Session.java:150)
at util.JschTransferlinuxWindows.main(JschTransferlinuxWindows.java:29)