I am using Jsch Library for SFTP. From My terminal, I have done ssh to the ftp machine, to add the ftp machine into known_host file. But when I am connecting to SFTP machine from Java using Jsch, it is not able to find out the host, also the ECDSA key fingerprint shown for the host in Java and in Terminal are different.
But I am not facing any issue in connecting to same host from python using pysftp.
If the host ip is same, why is Jsch getting a different signature ?
I have redacted hostname for security purpose. I have done sftp from terminal and added to known hosts.
here is the snippet of java code, which I am using to connect to sftp.
String host = platformDetailMap.get(Constants.SFTPProps.HOST);
String username = platformDetailMap.get(Constants.SFTPProps.USERNAME);
String password = platformDetailMap.get(Constants.SFTPProps.PASSWORD);
JSch ssh = new JSch();
Session session = null;
Channel channel = null;
try {
session = ssh.getSession(username, host, SFTP_PORT);
session.setPassword(password);
// java.util.Properties config = new java.util.Properties();
// config.put("StrictHostKeyChecking", "no");
// session.setConfig(config);
session.connect();
channel = session.openChannel(SFTP_CHANNEL_IDENTIFIER);
channel.connect();
ChannelSftp sftp = (ChannelSftp) channel;
List<SFTPFile> fileList = new ArrayList<SFTPFile>();
Vector<ChannelSftp.LsEntry> entryList = sftp.ls(path);
This is producing the following exception.