Public key authentication fails with JSch but work with OpenSSH with the same key

Your OpenSSH ssh connection is using rsa-sha2-512 key signature. While that does not prove that your server requires it, it’s quite probable that it does.


JSch does not support rsa-sha2. And as JSch seems not to be updated anymore, it quite likely never will.

There’s a fork of JSch that does though:
https://github.com/mwiede/jsch
At least test it, to verify that this is indeed the issue.


Another (less secure obviously) option is to reconfigure the server not to require the rsa-sha2 by adding deprecated ssh-rsa to PubkeyAcceptedAlgorithms.


Others might be getting the same error for different reasons. For example, when expecting the JSch to automatically pickup the default OpenSSH keys:
Getting “com.jcraft.jsch.JSchException: Auth fail” – but “ssh” can login using public key authentication

Leave a Comment