Simply trying to run the following Java code from Windows 10 to connect remote Linux server.
JSch jsch = new JSch();
Session session = jsch.getSession(username, host, port);
session.setConfig("StrictHostKeyChecking", "no");
session.setPassword(password);
session.connect();
But getting Error: com.jcraft.jsch.JSchException: Auth cancel
I can connect the same server from Putty though. In some other posts it was suggested to use setKnownHosts
method but not sure how to get that working.
JSch LOG (deleted few lines for security reasons):-
Connecting to xxx port xxx
Connection established
Remote version string: SSH-2.0-OpenSSH_5.3
Local version string: SSH-2.0-JSCH-0.1.54
...
...
aes256-ctr is not available.
aes192-ctr is not available.
aes256-cbc is not available.
aes192-cbc is not available.
CheckKexes: xxx
CheckSignatures: xxx
SSH_MSG_KEXINIT sent
SSH_MSG_KEXINIT received
...
...
SSH_MSG_KEXDH_INIT sent
expecting SSH_MSG_KEXDH_REPLY
ssh_rsa_verify: signature true
Permanently added xxx (RSA) to the list of known hosts.
SSH_MSG_NEWKEYS sent
SSH_MSG_NEWKEYS received
SSH_MSG_SERVICE_REQUEST sent
SSH_MSG_SERVICE_ACCEPT received
Authentications that can continue: keyboard-interactive,password
Next authentication method: keyboard-interactive
Disconnecting from xxx port xxx