Discussion

1
Replies
85
Views
X
SureshS Member since 2017 1 post
USAA
Posted: 1 year ago
Last activity: 1 year ago

JSCH exception Custom SFTP Error

We are trying to build a custom sftp to get a file from a remote machine and we are using pega 7.3.1 version (in Cloud) .But getting error

com.jcraft.jsch.JSchException: UnknownHostKey: xx.xx.xx.xx. RSA key fingerprint is 6a:ba:ab:12:fc:f2:bc:21:14:ae:af:bd:0c:02:ad:0d

below is the code snippet using JSCH

java.io.InputStream inputStream = null;
com.jcraft.jsch.ChannelSftp sftpChannel=null;
com.jcraft.jsch.Session ftpSession=null;
boolean isSuccess=false;
try {
com.jcraft.jsch.JSch jsch = new com.jcraft.jsch.JSch();
ftpSession = jsch.getSession(UserName,HostName,Port);
ftpSession.setPassword(Password);
ftpSession.connect();
oLog.error("Session connected ");
sftpChannel = (com.jcraft.jsch.ChannelSftp) ftpSession.openChannel("sftp");
sftpChannel.connect();
sftpChannel.put(new java.io.ByteArrayInputStream(LocalFile.getBytes()),remotePath,com.jcraft.jsch.ChannelSftp.OVERWRITE );
isSuccess=true;
}
catch (java.lang.Exception e) {
oLog.error(e.toString());
}
finally{
if (sftpChannel != null && sftpChannel.isConnected()) {
sftpChannel.disconnect();
}
if (ftpSession != null && ftpSession.isConnected()) {
ftpSession.disconnect();
}
}
return isSuccess;

***Edited by Moderator Marissa to update platform capability tags****

Data Integration Java and Activities Developer Knowledge Share
Share this page LinkedIn