Reasons for com.jcraft.jsch.JSchException: Auth fail

A 'kind-of nagios' (written in Java) monitors the webserver hosting these pages. It does so by programmatically accessing the server by ssh. Today, I stumbled upon an interesting behaviour: without any changes, the nagios and sshd (the ssh daemon outputs the error message by the client) displayed the Exception com.jcraft.jsch.JSchException: Auth fail. There are several reasons why this can happen:

1) Someone attacks your sever

The most probable answer. The software used, JSch, seems to be an great choice for developers who programmatically want to access their servers via ssh. Obviously not just the good guys. You have probably seen the following message in your server logs: 

May 9 08:24:58 srv sshd[22864]: error: Received disconnect from 212.83.163.138: 3: com.jcraft.jsch.JSchException: Auth fail [preauth]

If it is not your ip/client, than you want to ignore it. And if you have not done so yet, you should check out fail2ban and secure your ssh daemon!

2) Somehow the authentication of your client does not work

  • Check your user & password
  • And more important, check your 'authorized_keys' on the server. In my case, I could normally access via ssh client but NOT via the JSch. Replacing the public keys solved the problem 

Somehow, my authorized_keys got corrupt. Anyway, if these solutions do not help, activate debugging modes for SSH and JSch

References

Leave a Comment

comments powered by Disqus