Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using chef's knife ec2 tool which requires the name of a loaded SSH key (that was created in the Amazon EC2 control panel)

It seems strange to me that it uses a name to reference the keypair - because the name was created in the ec2 control panel:

Picture.png

When I download the file I am just getting the mykey.pem file. Does that somehow contain the encoded keypair name? This key pair's name does not seem to be visible at the command line:

$ ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQE69PeuHFtO[truncated]== /Users/me/mykey.pem

$ ssh-add -l
2048 b4:45:70:23:b1:f3:3b:01:11:23:45:67:89:0a:bc:de /Users/me/mykey.pem (RSA)

Questions

  1. Is there a keypair "name" somewhere that I'm missing? How can I view these?
  2. How does a third party software (like the knife tool) know which keypair to use based on the "name" of the keypair that appears invisible?

I hope those questions make sense - I'm happy to elaborate on any gray areas.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

(Long story short, it uses FOG.)

If I understood your question properly, I guess it comes from EC2 like this:

lib/chef/knife/ec2_server_create.rb knows something about the SSH key name in this section (def run):

server = connection.servers.create(create_server_def)
# ...
msg_pair("SSH Key", server.key_name)

this connection.servers.create can be found in lib/chef/knife/ec2_base.rb, where we find:

def connection
  @connection ||= begin
    connection = Fog::Compute.new(
      :provider => 'AWS',
      :aws_access_key_id => Chef::Config[:knife][:aws_access_key_id],
      :aws_secret_access_key => Chef::Config[:knife][:aws_secret_access_key],
      :region => locate_config_value(:region)
    )
  end
end

i.e. it uses FOG which talks to AWS and thus knows how to deal with the key name....I suppose (?)

share|improve this answer
    
ahhh! ok, makes perfect sense! it doesn't know from the key - it talks to amazon, which tells it which key is associated with the name! very enlightening! thanks so much!!!! –  cwd Mar 6 '12 at 17:43
    
You're welcome :) (I wish I would have found a way to get code highlighting, though...) –  sr_ Mar 6 '12 at 17:44
    
says you can specify it on this page (unix.stackexchange.com/editing-help) but i have not had luck with that either –  cwd Mar 6 '12 at 19:06
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.