Skip to content

Instantly share code, notes, and snippets.

@artizirk
Last active January 20, 2024 10:37
Show Gist options
  • Save artizirk/71d7ae140c58f38e45d84d34f7fcc341 to your computer and use it in GitHub Desktop.
Save artizirk/71d7ae140c58f38e45d84d34f7fcc341 to your computer and use it in GitHub Desktop.
Converting openssh private key format to pem

Converting openssh private key format to pem

man page says that you can use -e option to convert private and public keys to other formats, that seems to be wrong. Instead you can use -p option to request changing the password but not actually setting the password.

ssh-keygen -p -f id_rsa -m pem

Converting pem to OpenPGP

Monkeysphere project includes a pem2openpgp command that can be used to import ssh private keys to gnupg keyring.

PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp 'ssh id_rsa' < id_rsa | gpg --import

After importing you can use normal gpg --edit-key command to change parameters on this key. GnuPG 2.1 also allows you to move the imported key to be one of your subkeys for authentication. https://security.stackexchange.com/a/160847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment