내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

AEM JSCH auth faill issue

Avatar

Level 2

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 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 2

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. 

원본 게시물의 솔루션 보기

4 답변 개

Avatar

Level 10

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.

Avatar

Community Advisor

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

Avatar

Level 2

 

Is the private key in the correct format?

  • JSch does not support the new OpenSSH key format.

If your key starts with:

 

-----BEGIN OPENSSH PRIVATE KEY-----You need to convert it:
ssh-keygen -p -m PEM -f ~/.ssh/id_rsThis will create a format JSch can read.

Avatar

정확한 답변 작성자:
Level 2

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.