-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSch Authentication Failure: "Auth fail for methods 'publickey'" in AWS Lambda #750
Comments
Hi @ManojlovicM, We can't tell you why your remote server is rejecting your SSH authentication when you run it via an AWS Lambda. Thanks, |
Hi @norrisjeremy, Thank you for your quick response. The issue seems to be with the SFTP configuration, not the code. Best Regards, |
Hi @norrisjeremy, Sorry for reopening this ticket, but after further analysis, it seems the issue is not with AWS or SFTP configuration but rather with the inclusion of the JSCH library. When I run my code locally using the command: However, when I run it using: Could it be that the JSCH library is not being included properly in the JAR file during the build process? Please let me know if you need any additional details or logs. Best regards, |
Hi @ManojlovicM, What you described sounds like a problem with the packaging of your application and not JSch. Thanks, |
I'm encountering an issue with JSch when attempting to establish an SFTP connection using a private key from an AWS Lambda function. The connection fails with the error:
com.jcraft.jsch.JSchException: Auth fail for methods 'publickey'.
This is the stack trace for the error:
com.jcraft.jsch.JSchException: Auth fail for methods 'publickey' at com.jcraft.jsch.Session.connect(Session.java:520) at com.jcraft.jsch.Session.connect(Session.java:198) at org.equias.util.SftpUtil.getChannelSftpWithPvtKey(SftpUtil.java:96) at org.equias.service.processing.eex.EexProcessor.<init>(EexProcessor.java:49) at org.equias.aws.lambda.Handler.handleRequest(Handler.java:76) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$StreamMethodRequestHandler.handleRequest(EventHandlerLoader.java:831) at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2.call(EventHandlerLoader.java:601) at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:240) at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:190) at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:180)
I am using the following implementation to connect to the SFTP server using a private key:
`public static ChannelSftp getChannelSftpWithPvtKey(String remoteServer, Regions region)
throws JSchException {
LOGGER.info("Starting to get SFTP channel with private key for remote server: {}", remoteServer);
Runtime: AWS Lambda (Java 21)
JSch Version: 0.2.17
Could you please provide insights into why the authentication is failing in this specific case? Are there any additional configurations required for AWS Lambda environments or known issues with JSch in such setups?
Thank you for your assistance. Let me know if more details are needed!
The text was updated successfully, but these errors were encountered: