diff --git a/src/main/java/io/kestra/plugin/fs/sftp/SftpService.java b/src/main/java/io/kestra/plugin/fs/sftp/SftpService.java index 39e6743..bf3d282 100644 --- a/src/main/java/io/kestra/plugin/fs/sftp/SftpService.java +++ b/src/main/java/io/kestra/plugin/fs/sftp/SftpService.java @@ -57,6 +57,8 @@ public static FileSystemOptions fsOptions(RunContext runContext, SftpInterface s } if (sftpInterface.getKeyfile() != null) { + instance.setPreferredAuthentications(options, "publickey"); + File sftpKey = runContext.tempFile( runContext.render(sftpInterface.getKeyfile()).getBytes(StandardCharsets.UTF_8) ).toFile(); @@ -69,6 +71,8 @@ public static FileSystemOptions fsOptions(RunContext runContext, SftpInterface s } instance.setIdentityProvider(options, identityInfo); + } else { + instance.setPreferredAuthentications(options, "password"); } return options;