I am facing a issue with JSCH working fine outside the AEM. But failing inside AEM.
JSch jsch = new JSch(); // Add the private key identity jsch.addIdentity(privateKeyPath); // Get a session session = jsch.getSession(username, host, port); // Configure session properties Properties config = new Properties(); // Important: For testing, you might set StrictHostKeyChecking to "no" // In production, it's recommended to handle known_hosts properly. config.put("StrictHostKeyChecking", "no"); session.setConfig(config); // Connect to the session session.connect(); System.out.println("Session connected.");
This works perfectly when I run it directly with main method ( outside osgi). But gives the below error when code is ran inside AEM.
com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:519) at com.jcraft.jsch.Session.connect(Session.java:183)
I ran the code with java 11 and AEM is also running on java 11. The code inside AEM is also able to access the private key content. ( I checked with log)
I am using the new library https://github.com/mwiede/jsch
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks all. The issue was it was still wired to old bundle although i updated the dependence. I had to explicitly add a import package for the jsch with new version. Which resolved the issue.
I recommend creating a dedicated logger for the package com.jcraft.jsch and setting it to trace or debug level. This approach may provide additional information about the reason for the failure.
Hello @sharathn8223803
You can refer the implementation here - https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/ad... to compare any additional configurations required. Along with adding loggers for the specific package loggers as suggested by @giuseppebag
Thanks
Narendra
JSch does not support the new OpenSSH key format.
If your key starts with:
Thanks all. The issue was it was still wired to old bundle although i updated the dependence. I had to explicitly add a import package for the jsch with new version. Which resolved the issue.
Views
Likes
Replies
Views
Likes
Replies