I am able to connect to our SFTP server using WinScp(sftp client app) but before that i need to establish a session locally using MFA. Now i am trying to achieve this programmatically using JSch but i am getting SocketTimeoutException because i think it requires the same MFA setup to be done programmatically, if my understanding is correct then is there a way to achieve this using JSch ?
JSch jsch = new JSch();
Session session = jsch.getSession(userName, hostName, 22);
session.setPassword(password);
session.connect();
It throws exception at session.connect().
I am closing this question myself as there is no additional setup is required for this. From the machine on which this code is getting executed, if that machine has established the MFA session then it should work seamlessly and without making any other change. It did not work for me earlier because my MFA session was expired.