0
SFTPサーバーにファイルをアップロードするためにJavaコード(apache common vfs2を使用)を書きました。最近、自分のサーバーにPGPセキュリティを導入しました。今、Javaコードはこのサーバーに接続できません。 FileZillaとの接続は成功です。私たちはサーバー上ではCrushFTPを使用し、Javaアプリケーションではapache-common-vfs2を使用しています。ここでは、コードスニペットがSFTPサーバーに接続できませんApache共通
Caused by: org.apache.commons.vfs2.FileSystemException: Could not connect to SFTP server at "192.168.13.102".
at org.apache.commons.vfs2.provider.sftp.SftpClientFactory.createConnection(SftpClientFactory.java:170)
at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:97)
... 16 more
Caused by: 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:565)
Anoneyに従うように例外がある
String originalFileName = localFile.getName();
manager.init();
FileObject fileToUpload = manager.resolveFile(localFile.getAbsolutePath());
// Create remote file object
FileObject remoteFile = manager.resolveFile(
createConnectionString(originalFileName),
createDefaultFileSystemOptions());
remoteFile.copyFrom(fileToUpload, Selectors.SELECT_SELF);
方法
public String createConnectionString(String fileName) {
String path = "sftp://" + username + ":" + password + "@" + server +workingDir+"/"+fileName;
logger.info("uploading file at "+path);
return path;
}
public static FileSystemOptions createDefaultFileSystemOptions()
throws FileSystemException {
// Create SFTP options
FileSystemOptions opts = new FileSystemOptions();
// SSH Key checking
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
// Root directory set to user home
SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false);
// Timeout is count by Milliseconds
SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 10000);
return opts;
}
ある解決策を提案してください?
SFTPはOpenPGPプロトコルをまったくサポートしていませんが、代わりにTLS標準に依存しています。あなたはTLSで暗号化されたSFTPチャンネルを介してペイロードとしてOpenPGPで暗号化されたファイルを送信しているかもしれませんが、SFTP転送はOpenPGPとまったく関係ありません。 –