Q:

How do I verify that an ssh public/private keypair go together, is it different for openssl and ssh-key generated keys?

Generating a Private Key...
$ openssl genrsa -out ./oci_api_key.pem 2048

Generate a Public Key...from the private key:
I'm trying to generate a public key from a private key in PEM format (the Base64 of a DER) by running:
$ openssl rsa -pubout -in ./oci_api_key.pem -out ./oci_api_key_public.pem

Next I'd like to:
Verify they go together...by comparing their MODULUS...
Private Key Modulus:
$ openssl rsa -in ./oci_api_key.pem -noout -modulus
MODULUS=<long-hex-number>

Public Key Modulus (doesn't work):
$ openssl x509 -in ./oci_api_key_public.pem -noout -modulus

So what am I missing here?
    unable to load certificate
    140084471075264:error:0906D06C:PEM routines:PEM_read_bio:no start line:../crypto/pem/pem_lib.c:691:Expecting: TRUSTED CERTIFICATE
But it doesn't appear to work.  My public key doesn't have the TRUSTED CERTIFICATE line in it instead it's -----BEGIN PUBLIC KEY-----

A:

You need to add -pubin to your openssl rsa invocation to work with the public key:
$ openssl rsa -pubin -in ./oci_api_key_public.pem -noout -modulus

