How to convert RFC4716 private keys to PEM private keys in ubuntu 20.04?
For our project we generated ssh keys on a device running the latest openssh software. JSch complained about authentication:
Exception com.jcraft.jsch.JSchException: Auth fail
After a lot of research, including building a minimal git client we discovered a small change to our other key files. The header didn’t start with
—–BEGIN RSA PRIVATE KEY—–
but it started with
—–BEGIN OPENSSH PRIVATE KEY—–
showing, that this key is formatted in the new default RFC4716 format.
I have same question here, but I want to use my original key instead of regenerate one. And I don't want to use GUI applications like PuTTY. I want convert it in scripts.
I tried several attempts, non of these works:
ssh-keygen -f id_rsa -m 'PEM' -e
ssh-keygen -f id_rsa -e -m pem
# I got PUBLIC KEY instead of private key
openssl rsa -in ~/.ssh/id_rsa -outform pem
openssl rsa -in id_rsa -pubout -out id_rsa.pub.pem
openssl rsa -in ~/.ssh/id_rsaunable to load Private Key
# unable to load Private Key
# 139920849113728:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY
How do I convert it?