0

我正在尝试在私有子网上的 VPC 内启动一个 ec2 实例。每次运行时kitchen test,我都能够使用正确的安全组和正确的子网范围启动实例。当 test-kitchen 尝试通过 SSH 连接到实例时,它要求输入密码。但是,当我手动尝试 ssh ( ssh <private_ip> -i <path_to_ssh_key> -l ubuntu) 到机器上时,我成功了,而不会提示输入密码。

以下是我的 .kitchen.yml 文件

---
driver:
  name: ec2
  aws_ssh_key_id: id-spanning
  security_group_ids: ['sg-9....5']
  region: us-east-1
  availability_zone: us-east-1a
  require_chef_omnibus: true
  subnet_id: subnet-5...0
  associate_public_ip: false
  instance_type: m3.medium
  interface: private

transport:
  ssh_key: ~/.ssh/id-spanning.pem
  connection_timeout: 10
  connection_retries: 5
  username: ubuntu

provisioner:
  name: chef_solo

platforms:
  - name: Ubuntu-14.04
    driver:
      image_id: ami-8821cae0

suites:
  - name: default
     run_list:
   attributes:

我在环境变量上设置了 aws 凭据。以下是我的输出。

kitchen test
-----> Starting Kitchen (v1.4.0)
-----> Cleaning up any prior instances of <default-Ubuntu-1404>
-----> Destroying <default-Ubuntu-1404>...
   EC2 instance <i-16f468c6> destroyed.
   Finished destroying <default-Ubuntu-1404> (0m1.90s).
-----> Testing <default-Ubuntu-1404>
-----> Creating <default-Ubuntu-1404>...
   Creating <>...
If you are not using an account that qualifies under the AWS
free-tier, you may be charged to run these suites. The charge
should be minimal, but neither Test Kitchen nor its maintainers
are responsible for your incurred costs.

   Instance <i-8fad345f> requested.
   EC2 instance <i-8fad345f> created.
   Waited 0/300s for instance <i-8fad345f> to become ready.
   Waited 5/300s for instance <i-8fad345f> to become ready.
   Waited 10/300s for instance <i-8fad345f> to become ready.
   Waited 15/300s for instance <i-8fad345f> to become ready.
   Waited 20/300s for instance <i-8fad345f> to become ready.
   Waited 25/300s for instance <i-8fad345f> to become ready.
   EC2 instance <i-8fad345f> ready.
   Password: 

我尝试了几次,但在绕过密码以允许 test-kitchen ssh 到实例上时没有任何运气。以下是我的kitchen diagnose输出。

---
timestamp: 2015-05-26 15:34:29 UTC
kitchen_version: 1.4.0
instances:
  default-Ubuntu-1404:
    platform:
      os_type: unix
      shell_type: bourne
    state_file:
      hostname: ''
      server_id: i-1.....6
    driver:
      associate_public_ip: false
      availability_zone: us-east-1a
      aws_access_key_id: 
      aws_secret_access_key: 
      aws_session_token: 
      aws_ssh_key_id: id-spanning
      block_device_mappings: 
      ebs_optimized: false
      flavor_id: 
      iam_profile_name: 
      image_id: ami-8821cae0
      instance_type: m3.medium
      interface: private
      kitchen_root: "/Users/jonnas2/Desktop/apache101"
      log_level: :info
      name: ec2
      price: 
      private_ip_address: 
      region: us-east-1
      retryable_sleep: 5
      retryable_tries: 60
      security_group_ids:
      - sg-9....5
      shared_credentials_profile: 
      subnet_id: subnet-5....0
      tags:
        created-by: test-kitchen
      test_base_path: "/Users/jonnas2/Desktop/apache101/test/integration"
      user_data: 
      username: 
    provisioner:
      attributes: {}
      chef_metadata_url: 
      chef_omnibus_install_options: 
      chef_omnibus_root: "/opt/chef"
      chef_omnibus_url: https://www.chef.io/chef/install.sh
      chef_solo_path: "/opt/chef/bin/chef-solo"
      clients_path: 
      cookbook_files_glob: README.*,metadata {json,rb},attributes/**/*,definitions/**/*,files/**/*,libraries/**/*,providers/**/*,recipes/**/*,resources/**/*,templates/**/*
      data_bags_path: 
      data_path: 
      encrypted_data_bag_secret_key_path: 
      environments_path: 
      http_proxy: 
      https_proxy: 
      kitchen_root: "/Users/jonnas2/Desktop/apache101"
      log_file: 
      log_level: :info
      name: chef_solo
      nodes_path: 
      require_chef_omnibus: true
      roles_path: 
      root_path: "/tmp/kitchen"
      run_list: []
      solo_rb: {}
        sudo: true
      sudo_command: sudo -E
      test_base_path: "/Users/jonnas2/Desktop/apache101/test/integration"
    transport:
      compression: zlib
      compression_level: 6
      connection_retries: 5
      connection_retry_sleep: 1
      connection_timeout: 10
      keepalive: true
      keepalive_interval: 60
      kitchen_root: "/Users/jonnas2/Desktop/apache101"
      log_level: :info
      max_wait_until_ready: 600
      name: ssh
      port: 22
      ssh_key: "/Users/jonnas2/.ssh/id-spanning.pem"
      test_base_path: "/Users/jonnas2/Desktop/apache101/test/integration"
      username: ubuntu
    verifier:
      busser_bin: "/tmp/verifier/bin/busser"
      http_proxy: 
      https_proxy: 
      kitchen_root: "/Users/jonnas2/Desktop/apache101"
      log_level: :info
      name: busser
      root_path: "/tmp/verifier"
      ruby_bindir: "/opt/chef/embedded/bin"
      sudo: true
      sudo_command: sudo -E
      suite_name: default
      test_base_path: "/Users/jonnas2/Desktop/apache101/test/integration"
      version: busser

使用的版本: test-kitchen 1.4.0 kitchen-ec2 0.9.0

任何帮助将不胜感激。谢谢。

4

1 回答 1

0

此问题已由 test-kitchen 1.4.1 解决。如果配置了 ssh_key,则将修复(https://github.com/test-kitchen/test-kitchen/pull/704] )合并到核心 test-kitchen 中禁用密码验证。

于 2015-07-21T17:00:52.663 回答