Skip to content

Instantly share code, notes, and snippets.

@saikocat
Created July 16, 2020 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saikocat/c82564849431a46e14dd8cd1af5c6887 to your computer and use it in GitHub Desktop.
Save saikocat/c82564849431a46e14dd8cd1af5c6887 to your computer and use it in GitHub Desktop.
JGit and invalid private key
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@e4487af

The root cause was discovered to be the ssh private key mismatch. The exception only happened for users with key of newer kind ed25519, which outputs this key header:

-----BEGIN OPENSSH PRIVATE KEY-----

instead of kind RSA:

-----BEGIN RSA PRIVATE KEY-----

regenerating an RSA key (ssh-keygen -t rsa), made the exception go away. If you have OpenSSH 7.8 and above you might need to add -m PEM to the generation command:

ssh-keygen -t rsa -m PEM

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment