groovy-ssh icon indicating copy to clipboard operation
groovy-ssh copied to clipboard

New header for id_rsa on macOs

Open katoquro opened this issue 6 years ago • 3 comments

Environment info

groovy-ssh 2.10.1 openjdk version "11.0.3" 2019-04-16 LTS groovy 2.5.7 jsch 0.1.55

Steps to reproduce

  1. generate new key (like in https://github.com/int128/docker-sshd : ssh-keygen -t rsa -N '' -C '' -f id_rsa )
  2. use generated key
  3. get exception java.lang.RuntimeException: java.lang.RuntimeException: com.jcraft.jsch.JSchException: invalid privatekey: [B@79f7005

According to this issue appears after ssh-keygen update because the header of the file was changed from -----BEGIN RSA PRIVATE KEY----- to -----BEGIN OPENSSH PRIVATE KEY-----

Workaround

with additional flag -m PEM key will be generated with old header.

Most of the people generate key using github guide or something like that and it leads to issues with groovy-ssh lib. So support of this ssh-keygen update is highly desirable.

I've generated keys from mac os with new version of ssh-keygen (ssh-keygen -t rsa -N '' -C '' -f id_rsa) keys.zip . You can use it to debug

Thank you!

p.s. Is it possible to combine ssh related repos in one or make one multirepo with git-submodules? It's quite difficult to setup the whole env from scratch to debug the problem or run tests. And having all ssh-related issues in one repo also can be a bit convenient

katoquro avatar Sep 28 '19 11:09 katoquro

I tried it also with the -m PEM Option and I can‘t get an working solution. I use ssh-steps plugin with Jenkins. Ssh-steps plugin uses groovy-ssh as dependency. and I think Groovy-ssh uses as Dependency jsch-1.55, which looks like not active developed. But a few hours ago @mwiede has forked jsch (https://github.com/mwiede/jsch). If I understood it correct he has applied some fixes to get it working with the newer ssh-keys. Have a look at the jsch bug tracker https://sourceforge.net/p/jsch/bugs/119/#efc6 ...

is this repository maintained?

tobiashochguertel avatar May 30 '20 13:05 tobiashochguertel

I have implemented support for openssh private key format in https://github.com/mwiede/jsch It is now released https://search.maven.org/artifact/com.github.mwiede/jsch/0.1.60/jar you can give it a try.

mwiede avatar Oct 16 '20 13:10 mwiede

@mwiede nice to hear. Thank you for the contribution but we moved from groovy-ssh to https://mina.apache.org/sshd-project/

groovy-ssh lib has more convenient api than sshd but looks abandoned. May be we will make something like groovy-ssh on top of apache mina sshd. Currently ssh covers all our cases and even more

katoquro avatar Oct 19 '20 08:10 katoquro