我想连接到使用SFTP的密码较少配置的服务器。 使用终端,Sftp连接成功。 但是,当我通过用户名和密码连接到JAVA(使用Jsch库)时,我无法连接。 我的Java代码: -SFTP连接失败,由于java.security.InvalidAlgorithmParameterException
try {
try {
jsch.addIdentity(ftp_Info.getSftpCertFile());
} catch (Exception e) {
// TODO: Add a log message
}
session = jsch.getSession(ftp_Info.getUserName(), ftp_Info.getHost(), ftp_Info.getPort());
String pswd = (password_encypted) // password encryption
session.setPassword(pswd);
session.setConfig("StrictHostKeyChecking", "no");
session.setConfig("PreferredAuthentications", "password,hostbased,publickey");
session.connect(); // exception occurred here
session.setTimeout(connectionTimeOut);
Channel channel = session.openChannel(SFTP);
channel.connect();
sftpChannel = (ChannelSftp) channel;
} catch (Exception e) {
log.error(e.getMessage(), e);//error logged here
}
我得到以下异常: -
com.jcraft.jsch.JSchException: Session.connect: java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 1024 (inclusive) at com.jcraft.jsch.Session.connect(Session.java:485) at com.jcraft.jsch.Session.connect(Session.java:149)
请在故障排除或解决它帮助。 除了任何第三方服务提供商使我的2048位密钥传递此异常之外,有什么方法吗?
我怀疑这是你的加密套件的问题。您可能要切换到使用BouncyCastle提供程序。你在用什么JDK? –
我正在使用jdk 1.7 –