SSH Private Keys - RSA vs. OpenSSH

It would seem that ssh-keygen on OS X Mojave generates OpenSSH Private Keys instead of the traditional RSA Private Keys. While on the surface this is not a problem at all, it recently created a problem for us in combination with our use of the net-ssh Ruby gem, specifically that only RSA Private Keys are supported by this particular version of the gem, unless other dependencies are explicitly installed. So there would appear to be two solutions to this problem. First, we could update the net-ssh gem or discover/install whatever other dependencies are required to support OpenSSH Private Keys. Option two is to convert the existing private key from OpenSSH to RSA. The man page for ssh-keygen is helpful, but not nearly clear enough for this use case, so I'm documenting it here because I'm sure it'll come back to bite me again in the future.

Assuming ~/.ssh/id_rsa starts with:

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

Run ssh-keygen -p -m PEM -f ~/.ssh/id_rsa and you will find that the file now starts with:

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

Comments

Popular posts from this blog

Google Wifi and Verizon FiOS