如何按名称引用加载的 SSH 密钥?

cwd*_*cwd 4 linux security ssh authentication ssh-agent

我正在使用厨师刀 ec2 工具,它需要加载的 SSH 密钥的名称(在 Amazon EC2 控制面板中创建)

它使用名称来引用密钥对对我来说似乎很奇怪- 因为该名称是在 ec2 控制面板中创建的:

图片.png http://img843.imageshack.us/img843/4236/pictureiy.png

当我下载文件时,我只是在获取mykey.pem文件。这是否以某种方式包含编码的密钥对名称?此密钥对的名称在命令行中似乎不可见:

$ 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)
Run Code Online (Sandbox Code Playgroud)

问题

  1. 是否有我遗漏的密钥对“名称”?我怎样才能看到这些?
  2. 第三方软件(如刀具工具)如何根据看起来不可见的密钥对的“名称”来知道使用哪个密钥对?

我希望这些问题是有道理的 - 我很乐意详细说明任何灰色区域。

sr_*_*sr_ 5

(长话短说,它使用FOG。)

如果我正确理解了您的问题,我想它来自 EC2,如下所示:

lib/chef/knife/ec2_server_create.rb了解本节中def run的 SSH 密钥名称( )

server = connection.servers.create(create_server_def)
# ...
msg_pair("SSH Key", server.key_name)
Run Code Online (Sandbox Code Playgroud)

connection.servers.create可以在lib/chef/knife/ec2_base.rb我们找到

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
Run Code Online (Sandbox Code Playgroud)

即它使用FOG与 AWS 对话,因此知道如何处理密钥名称......我想(?)