I need to check the health of the SFTP connection. How to check SFTP connection successful or not in Spring boot(with a try-catch)? Which library should I use to check the SFTP connection in Spring?
Please check this link. Hope you will get your answer. Though I am copying some code snippet for your help.
.....
jsch = new JSch();
session = jsch.getSession(user, hostIP, port);
session.setPassword(Password);
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.connect(getTimeInSecond() * 1000);
channel = session.openChannel("sftp");
channel.connect();
channelSftp = (ChannelSftp) channel;
channelSftp.cd(LocationPath);
...
Thanks