Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert RSA to OPENSSH

I will preface this that I am extremely inexperienced with certs/keys and I am using a Mac.

My problem is with RSA and OPENSSH certs/keys. I currently have a valid RSA cert/key, but I need to convert them to OpenSSH. From my understanding, I want to do the opposite of this thread: Openssh Private Key to RSA Private Key

I have a file that starts with:

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

But I need to convert it to this:

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

I have tried ssh-keygen -p -N "" -m pem -f /path/to/key and ssh-keygen -f /path/to/key -m pem but it does not output with the OPENSSH header I expected.

  1. Is this possible?
  2. If it is possible, what can I use to perform this conversion and what would a potential command be?
  3. Do I need to do anything to convert the cert if I converted the key?
  4. If I do need to convert the cert, what is the command for that?
  5. If there is any further explanation on what converting from RSA to OPENSSH is, I would really appreciate it.
like image 958
Impurity Avatar asked Dec 22 '22 15:12

Impurity


1 Answers

As long as you are using -m PEM in your command, the result won't be an OPENSSH format.

This will convert an RSA/PEM private key into an OPENSSH one:

ssh-keygen -p -N "" -f /path/to/key

You can then extract its public key and confirm it is identical to the one you have before:

ssh-keygen -y -f /path/to/key
like image 97
VonC Avatar answered Jan 03 '23 20:01

VonC