I have two VM's. On machine 'A' SSH login happens using Private Key and on machine 'B' login happens using UserName and Pwd.
So, I would like to keep my code generic for both the systems. Let me know is this possible, if yes can you help me out.
jsch.addIdentity(Private_Key_Path);
session = jsch.getSession(telnetUser, telnetHost, port);
session.setConfig("PreferredAuthentications", "publickey,keyboard-interactive,password");
session.setPassword(telnetPwd);
session.setConfig("config");
session.connect();