Kitchen-EC2 Waiting for SSH Service" loop Error(Ubuntu Image)!

Hi I was trying to create a ubuntu instance using kitchen-ec2,

It could successfully create EC2 instance. But after that it is getting into a loop like this,

_`-----> Starting Kitchen (v1.8.0)_
_-----> Creating <kitchen-logstash-ubuntu-1604>..._
_       Detected platform: ubuntu version 16.04 on x86_64. Instance Type: t2.micro. Default username: ubuntu (default)._
_       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-31f4e995> requested.
   Polling AWS for existence, attempt 0...
   Attempting to tag the instance, 0 retries
   EC2 instance <i-31f4e995> created.
   Waited 0/300s for instance <i-31f4e995> to become ready.
   Waited 5/300s for instance <i-31f4e995> to become ready.
   Waited 10/300s for instance <i-31f4e995> to become ready.
   Waited 15/300s for instance <i-31f4e995> to become ready.
   Waited 20/300s for instance <i-31f4e995> to become ready.
   Waited 25/300s for instance <i-31f4e995> to become ready.
   EC2 instance <i-31f4e995> ready.
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds
   Waiting for SSH service on 10.10.70.176:22, retrying in 3 seconds

`

The subnet in which EC2 instance runs is a private subnet. and its connected to internet through a NAT instance. And also that subnet is accessible from my work station through our VPN. I could manually ssh to the server easily. But test kitchen fails to SSH to it.

Helps would be appreciated.

Just guessing here, but do you have per-host configuration or anything in your SSH config? The ruby SSH library only understands some of the SSH config file.

Hi @kallistec

i have tried removing my config(./ssh/config) file from my ssh directory and ran kitchen create. No luck. Same issue :frowning:

Again, I’m just guessing since I can’t find any clues in your logs. But my suspicion was that your manual ssh command worked correctly because of something in your ssh config, which you might need to apply in some way to kitchen. Can you ssh in manually with a default config?

Manual SSH is nothing related with config. i just put this to manual ssh,

ssh -i "sysadmin.pem" ubuntu@10.10.70.176
Here’s my kitchen.yml file here. Please chef if anything is wrong in it,

---
driver:
  name: ec2
  aws_ssh_key_id: sysadmin
  region: ap-south-1
  instance_type: t2.micro  
  security_group_ids: ["sg-xxxxx"]
  subnet_id: subnet-xxxxx
  require_chef_omnibus: true

transport:
  ssh_key: .ssh/sysadmin.pem
  

provisioner:
  name: chef_zero

platforms:
  - name: ubuntu-16.04
    image_id: ami-fbe83c98
  

suites:
  - name: default
    run_list:
      - recipe[my-elasticsearch::default]
    attributes:
      java:
        jdk_version: "8"

Try using the full path to your SSH key in your kitchen config. You can
also specify the SSH user, although I don’t think that’s the problem.

That worked :slight_smile: Thanks alot