I’m documenting this since I ran into a couple of snags while trying to convert an open SSH key (that doesn’t play well with Node) into an RSA PKCS1 format in the command line.
The snippets below assume your private key file is called
private.key and you’re currently in the same directory as the private key file.
The command you need is this:
ssh-keygen -p -N "" -m pem -f private.key
However, I ended up getting this error:
Permissions 0777 for 'private.key' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
I solved this👆 issue with:
chmod 600 private.key
Then I ran into the following error:
Key has comment 'This is a comment'
I needed to remove this comment, which I did using:
ssh-keygen -c -C "" -f private.key
After these steps, the original command worked great 🎉
ssh-keygen -p -N “” -m pem -f private.key