【发布时间】:2021-12-25 01:16:51
【问题描述】:
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 !!");
}
}
执行上述代码后出现以下错误:
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)
【问题讨论】:
-
这个问题与 Selenium 有什么关系?
-
为了找出根本原因你需要给我们jsch logger的输出。
-
请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。