Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a .pem private key generated by openssl. How to extract the key ID from it?

Edit: the generated rsa keypair is for Amazon cloudfront. When uploaded on the console, a 'Key ID' is displayed. However the private key I have generated is not for my account and I don't have any slot available to upload the public key on my AWS account (there's a limit of 2 public keys).

share|improve this question
1  
Is there any specific program that requires you to enter such a key ID? –  grawity Sep 27 '11 at 11:52
add comment

2 Answers

up vote 3 down vote accepted

Bare keys do not have "key IDs". They're just series of numbers.

If the key belongs to an X.509 certificate, then the certificate's fingerprint (a SHA-1 hash of the DER-encoded cert) will be used for identification: openssl x509 -outform der | openssl sha1, or openssl x509 -noout -fingerprint.

Otherwise (if it's just a bare public/private keypair), the SHA-1 hash of the public key is used sometimes (again, DER encoding), but I don't know of any standard for it. You can extract the public key with openssl rsar -pubout -outform der, again piping to openssl sha1 if that's what your program requires.


The "key pair IDs" used by CloudFront are serial numbers of the database entry with that key. The same key, uploaded twice, will have different IDs; I just tested it.

share|improve this answer
    
thanks. I have edited my question. It looks like the way to generate this AWS 'key ID' is proprietary, so my question is just plain wrong... –  ascobol Sep 27 '11 at 12:49
    
CloudFront key IDs are indeed proprietary; see updated answer. –  grawity Sep 27 '11 at 12:57
add comment

Amazon now provides tools for performing such actions on any server (not just servers running in EC2). On any Ubuntu computer you can install the tools with apt-get:

$ sudo apt-get install ec2-ami-tools ec2-api-tools

Here is the syntax to get the fingerprint for My.pem:

$ ec2-fingerprint-key My.pem
62:44:56:f7:91:f2:8b:9b:44:7c:17:0e:39:c7:34:68:f5:b2:3c:57

As ec2-fingerprint-key is a bit long to type, there is an equivalent shortcut ec2fp:

$ ec2fp My.pem
62:44:56:f7:91:f2:8b:9b:44:7c:17:0e:39:c7:34:68:f5:b2:3c:57
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.