【问题标题】:Changing ssh keypair when creating an ec2 instance with chef使用 Chef 创建 ec2 实例时更改 ssh 密钥对
【发布时间】:2015-12-22 06:51:08
【问题描述】:

我正在创建一个基于内部 AMI 的 ec2 实例,该实例使用不同的 ssh 密钥进行身份验证,而不是我想在使用刀创建的实例上使用的那个(在示例中,我称之为 original-pem -for-ami.pem):

knife ec2 server create  -I ami-0123456 -f m2.xlarge \
  --ssh-user username --groups sg-1234 \
  --identity-file ~/.ssh/original-pem-for-ami.pem \ 
  --node-name solr1 --hint ec2 -a public_ip_address \
  --ssh-key name-of-key-i-want-to-use-to-login-to-new-instance

当我运行此命令时,服务器正确启动,分配了正确的安全组等,但我只能使用以下方式连接它:

ssh -i ~/.ssh/original-pem-for-ami.pem username@assigned-ec2-public-dns-name

有没有办法让新实例成为与命名密钥对 name-of-key-i-want-to-use-to-login-to-new-instance 关联的密钥。我认为使用 --ssh-key name-of-key-i-want-to-use-to-login-to-new-instance 可以做到这一点。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 chef-infra knife


    【解决方案1】:

    检查您拥有哪个版本的knife-ec2。 --ssh-key 在 0.12 中是正确的,但在此之前(0.11 及更早版本)我认为它有所不同。还要确保这可以通过普通的 AWS 工具进行,因为 AMI 可能没有正确准备并使用了硬连线密钥。

    【讨论】:

    • 问题是未正确准备 AMI。谢谢
    猜你喜欢
    • 1970-01-01
    • 2011-12-14
    • 2013-07-18
    • 1970-01-01
    • 2019-02-10
    • 2019-02-26
    • 2020-04-04
    • 2014-08-16
    • 2017-04-03
    相关资源
    最近更新 更多