Skip to content

Instantly share code, notes, and snippets.

@zircote
Created September 26, 2011 21:45
Show Gist options
  • Save zircote/1243501 to your computer and use it in GitHub Desktop.
Save zircote/1243501 to your computer and use it in GitHub Desktop.
Convert a AWS PEM into a ssh pub key
ssh-keygen -y -f private_key1.pem > public_key1.pub
@pony012
Copy link

pony012 commented May 26, 2023

@Faishal24 , @ricsaka , maybe you need to pass the param -m PKCS8

ssh-keygen -y -f private_key1.pem -m PKCS8 > public_key1.pub 

From the manual:

 -m key_format
        Specify a key format for the -i (import) or -e (export) conversion options.  The
        supported key formats are: “RFC4716” (RFC 4716/SSH2 public or private key), “PKCS8”
        (PEM PKCS8 public key) or “PEM” (PEM public key).  The default conversion format is
        “RFC4716”.

@danelec-hpm
Copy link

danelec-hpm commented Jul 10, 2024

My solution to Load key invalid format was to use -i instead of -y
ssh-keygen -i -m PKCS8 -f cert.pem > cert.pub

@coolpie72
Copy link

this works for me for AWS key pair with type ed25519

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