Skip to content

Instantly share code, notes, and snippets.

@perja12
Last active September 24, 2024 03:46
Show Gist options
  • Select an option

  • Save perja12/a3f41046e618f031a65b02e6c17e75d8 to your computer and use it in GitHub Desktop.

Select an option

Save perja12/a3f41046e618f031a65b02e6c17e75d8 to your computer and use it in GitHub Desktop.
Convert SSH private key to classic format

If you generate a key pair with ssh-keygen you can, depending on version, get a private key with the header

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

This type of key is not compatible with f.ex. jsch and needs to be converted so that it has the header

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

They way to convert existing keys is as follows: ssh-keygen -p -m PEM -f yourkeyfile

This command is for setting a new passphrase for your private key, but since the -m PEM flag is there it will write the key in the classic format.

@Tattoobeauty
Copy link

ssh-keygen -p -m PEM -f yourkeyfile

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