我刚刚设立了一个新的厨师环境,因为我正在扩大我对厨师的知识。 我有一个在EC2上设置的密钥对,我有我的刀子configuration设置。 当我尝试产生一个服务器,节点被创build,但刀不能ssh进入它。
这是我的knife.rb (这是回购之外):
current_dir = File.dirname(__FILE__) log_level :info log_location STDOUT node_name "mynode" client_key "/Users/me/.chef/my.pem" validation_client_name "my-validator" validation_key "/Users/me/.chef/my-validator.pem" chef_server_url "https://api.opscode.com/organizations/myorg" cache_type 'BasicFile' cache_options( :path => "/Users/me/.chef/checksums" ) cookbook_path ["/Users/me/git/chef/cookbooks"] knife[:aws_access_key_id] = "yadayadyada" knife[:aws_secret_access_key] = "blahblahblah" knife[:identity_file] = "/Users/me/.ssh/knife.pem" knife[:aws_ssh_key_id] = "knife"
这是我的刀子命令:
knife ec2 server create -r "role[whatever]" -I ami-09470539 --subnet subnet-03e44866 -f t2.micro --ssh-user ubuntu --region us-west-2 -Z us-west-2a
我也试过直接指定pem :
knife ec2 server create -r "role[whatever]" -I ami-09470539 --subnet subnet-03e44866 -f t2.micro -S knife -i ~/.ssh/knife.pem --ssh-user ubuntu --region us-west-2 -Z us-west-2a
这是VPC组内的HVM实例。
我试过并检查了…
pem有正确的权限(400)。 knife.pem键直接ssh进入它。 还有什么我失踪?
在详细模式下,这是我所看到的…
Waiting for sshd .DEBUG: ssh timed out: 172.nnn.nnn.nnn .DEBUG: ssh timed out: 172.nnn.nnn.nnn
当我第一次在EC2上设置厨师时遇到了这个问题。 以下是我们用于成功启动EC2实例的命令:
knife ec2 server create \ --flavor m3.medium \ --image ami-****** \ --iam-profile "iam-app" \ --ebs-size 30 \ --security-group-ids sg-**** \ --subnet subnet-6de**** \ --ssh-key my-key-name \ --ssh-user ubuntu \ --ssh-port 22 \ --identity-file "/local/path/to/ssh/key/for/this/instance" \ --ssh-gateway [email protected] \ #remove this line if you're not connecting through a bastion host --server-connect-attribute private_ip_address \ # Because we connect through a bastion host we want to explicitly connect to the the private IP address. You may want to set this to the public IP address. I believe these are fog attributes. --node-name "test-play-1" \ --tags Name="test-play-1",Environment="Test" \ --run-list "role[app]" \ --environment test
请注意,最好使用Bastion主机连接到您的实例,而不是直接连接到每个EC2实例。 另外,对于面向公众的服务器,我们使用这样一行来显式分配弹性IP地址:
--associate-eip 54.186.***.***
只是想添加没有堡垒主机的工作,因为它花了很多的实验:
knife ec2 server create --image ami-xxxxx \ --flavor t2.medium \ --run-list 'recipe[recipe-name]' \ --security-group-id sg-xxxxx \ --region us-east-1 \ --node-name $1 -T Name=$1 \ --subnet subnet-xxxxx \ --ssh-user ubuntu \ --ssh-key key_name \ --identity-file "~/.ssh/key_file_name" \ --server-connect-attribute dns_name \ --associate-eip $2 \ --associate-public-ip \ --no-host-key-verify
第一个参数是实例名称,第二个参数是公共弹性IP。
干杯!
当然,一旦我离开电脑,我意识到这个问题是什么…
knife正试图在使用私有IP ssh。 D'哦!
我只能假设--associate-public-ip会解决这个问题。 我远离电脑,稍后再testing。 随意确认/否定/提供build议。
由于我通过公共IP连接,并且此--server-connect-attribute public_ip_address为我工作。