jsch
jsch copied to clipboard
Two factor authentication using password and public Key
We have a SFTP Server which uses both password and publicKey for authentication on Bitvise. Our SftpClient is using jsch 0.2.19. We have incorporated addIdentity and set password on our session. We have also implemented UserInfo, UIKeyboardInteractive in our SFTPUserInfo class, and set the the session with user info as follows:
session.setUserInfo(new SFTPUserInfo(username, password, passphrase);
In our code, the preferredAuthentications we mentioned are publickey,password,keyboard-interactive
After these changes, we have used a Bitvise SSH Server to check the authentication that's happening. We notice that public key is being used to authenticate, only in the case that public key is invalid, it falls back to password (We think this ordering is due to the order of our preferredAuthentications). Our expectation is that at all times both public key and password are used for two factor authentication. Is there anything we are missing here to have two factor authentication working?