Amit Mishra
Amit Mishra

Reputation: 69

SSH RSA public key in PKCS1 format issue

I've created private & public key using GIT bash. I got id_rsa as private & id_rsa.pub as public key from ssh-keygen -t rsa -b 4096 command. The problem is when i am using c# code for abenity api, it gives error that "Not an RSA key". My private key is as follows-

-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEAvg5KIzv59e9l9OKhRorkGQloGH60jMRCdiyxVPZtHDGfbr+N
I5RIpvuv5rhE2ADm+LsaF7HkInEslTVwjjg2piznkc99yAm7y2PsBJQDvhbvdXtM
eJV1JzFEKzBcbuPvVZ/wmcdSENmUXgz
ZltPdTX9WPYPQqmMb6iS+NRqowvYV7zzJTsuL6rDmRGhReH0R27yDihEFx8hC6mQ
x+r..............................Ir2NLnc=
-----END RSA PRIVATE KEY-----

And my public key as follows -

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC................G+KssB6SPx+WbGpmW 

I think my public key should be in PEM Format:

-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEA05ulw0FHaD3yCw8zPhav2lVdasl5waVSyl
MKvJ+YJuE9hifO3R8XslKWYW2cOTg0QPQIDAQAB
-----END RSA PUBLIC KEY-----

However, i do not know how to convert it into above format. Need help!

Thanks in advance.

Upvotes: 5

Views: 2441

Answers (1)

phd
phd

Reputation: 94397

Export the key:

ssh-keygen -e -f ~/.ssh/id_rsa.pub -m pem >ssh-pub.pem

Upvotes: 3

Related Questions