"JSchException: invalid privatekey" on OpenSSH 7.8 and above
Status: Alpha
Brought to you by:
ymnk
steps
problem
See for example https://stackoverflow.com/a/53783283/3827
Caused by: com.jcraft.jsch.JSchException: invalid privatekey: [B@e4487af
at com.jcraft.jsch.KeyPair.load(KeyPair.java:664)
at com.jcraft.jsch.KeyPair.load(KeyPair.java:561)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:407)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:367)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getJSch(JschConfigSessionFactory.java:276)
at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:220)
at org.eclipse.jgit.transport.JschConfigSessionFactory.createSession(JschConfigSessionFactory.java:176)
at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:110)
expectation
This should work.
notes
https://www.openssh.com/txt/release-7.8
- ssh-keygen(1): write OpenSSH format private keys by default
instead of using OpenSSL's PEM format. The OpenSSH format,
supported in OpenSSH releases since 2014 and described in the
PROTOCOL.key file in the source distribution, offers substantially
better protection against offline password guessing and supports
key comments in private keys. If necessary, it is possible to write
old PEM-style keys by adding "-m PEM" to ssh-keygen's arguments
when generating or updating a key.
This is affecting JGit and their users https://bugs.eclipse.org/bugs/show_bug.cgi?id=558448
+1 we are also interested in having this work for SFTP connections.
Hello Radu Coravu, It looks like that there is now someone how forked this project https://sourceforge.net/p/jsch/bugs/119/#efc6
Thanks Tobias, I will keep this in mind.