vinay vinay - 1 year ago 221
Java Question

"com.jcraft.jsch.JSchException: Auth fail" with working passwords

While trying to upload the file to our server, i am getting the following exception

com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(
at com.jcraft.jsch.Session.connect(
at FtpService.transferFileToReciever(
at FtpService.transferFileToReciever(
at FtpService.transferFileToRecievers(
at FtpService.transferSingeFile(
at FtpService.main(
Auth fail

The part of function transferFileToReciever from source file is

JSch jsch = new JSch();
Session session = jsch.getSession(username, host, 22);

session.connect(); //geting exception here

boolean ptimestamp = true;

The passwords are working, since i can do login using ssh, but using JSCh it doesnt work even provided with key, username and password.
Using id_dsa key with java version "1.6.0_25".
What could be the error?

Found other similar question, but not the answer.
Thanks in advance.

Answer Source

Tracing the root cause, i finally found that the public key of type dsa is not added to the authorized keys on remote server. Appending the same worked for me.

The ssh was working with rsa key, causing me to look back in my code.

thanks everyone.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download