TCP ssh wait failed on vagrant-kitchen

I am using vagrant for test-kitchen on windows environment and it isn’t working.

Vagrant works fine on its own, vagrant init bento/centos-7.3, vagrant up and ssh 127.0.0.1 -p 2222 all work fine.

It is not an issue of Bios/enabling virtualization of 64bit because the above works.

Versions:
Vagrant 2.0.0
.\vboxmanage -v
5.1.26r117224

Chef Development Kit Version: 2.0.28
chef-client version: 13.2.20
delivery version: master (17c1b0fed9be4c70f69091a6d21a4cbf0df60a23)
berks version: 6.2.0
kitchen version: 1.16.0
inspec version: 1.31.1

kitchen destroy has been used each time before creating.
The test kitchen each time gets stuck on "Waiting for SSH Service on 127.0.0.0.1:2222"
Which is Odd because when it is waiting, I issued an ssh to this port and it succeeded.

ssh 127.0.0.1 -p2222

vagrant 127.0.0.1’s password:
[vagrant default-centos-73 ~]$ who am i

kitchen create
-----> Starting Kitchen (v1.16.0)
-----> Creating …
Users\kgstst0mBringing machine ‘default’ up with ‘virtualbox’ provider…Users\kgstst0m
Users\kgstst1m==> default: Importing base box ‘bento/centos-7.3’…Users\kgstst0m
Users\kgstst0m
1m==> default: Matching MAC address for NAT networking…Users\kgstst0m
Users\kgstst1m==> default: Checking if box ‘bento/centos-7.3’ is up to date…Users\kgstst0m
Users\kgstst1m==> default: Setting the name of the VM: kitchen-learn_chef_httpd-default-centos-73_default_1505469876960_1655Users\kgstst0m
Users\kgstst1m==> default: Clearing any previously set network interfaces…Users\kgstst0m
Users\kgstst1m==> default: Preparing network interfaces based on configuration…Users\kgstst0m
Users\kgstst0m default: Adapter 1: natUsers\kgstst0m
Users\kgstst1m==> default: Forwarding ports…Users\kgstst0m
[0m default: 22 (guest) => 2222 (host) (adapter 1)Users\kgstst0m
Users\kgstst1m==> default: Booting VM…Users\kgstst0m
Users\kgstst1m==> default: Waiting for machine to boot. This may take a few minutes…Users\kgstst0m
Users\kgstst0m default: SSH address: 127.0.0.1:2222Users\kgstst0m
Users\kgstst0m default: SSH username: vagrantUsers\kgstst0m
Users\kgstst0m default: SSH auth method: private keyUsers\kgstst0m
Users\kgstst0m default: Warning: Connection reset. Retrying…Users\kgstst0m
Users\kgstst0m default: Warning: Connection aborted. Retrying…Users\kgstst0m
Users\kgstst0m default: Warning: Connection reset. Retrying…Users\kgstst0m
Users\kgstst0m default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.Users\kgstst0m
Users\kgstst0m default:
default: Inserting generated public key within guest…Users\kgstst0m
Users\kgstst0m default: Removing insecure key from the guest if it’s present…Users\kgstst0m
Users\kgstst0m default: Key inserted! Disconnecting and reconnecting using new SSH key…Users\kgstst0m
Users\kgstst1m==> default: Machine booted and ready!Users\kgstst0m
Users\kgstst1m==> default: Checking for guest additions in VM…Users\kgstst0m
Users\kgstst1m==> default: Setting hostname…Users\kgstst0m
Users\kgstst1m==> default: Mounting shared folders…Users\kgstst0m
Users\kgstst0m default: /tmp/omnibus/cache => C:/Users/kgs-humayun.manzer/.kitchen/cacheUsers\kgstst0m
Users\kgstst1m==> default: Machine not provisioned because --no-provision is specified.Users\kgstst0m
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds

There was a pretty nasty bug specifically on Windows with kitchen-vagrant 1.2.0 and you’ll want a newer DK, 2.2+ to get the fix. If it’s still occurring after an upgrade we’d also need to check the version of the bento box you’re using vagrant box list.

Cheers,

It is still happening. Retrial attempt below. I have upgraded new chefDK 2.3.1

Chef Development Kit Version: 2.3.1
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

These are the boxes. I am primarily using Centos-7.3 and ubuntu-14.04
These are advised in the learn chef rally.

bento/centos-7.3 (virtualbox, 201708.22.0)
bento/ubuntu-14.04 (virtualbox, 201708.22.0)
bento/ubuntu-16.04 (virtualbox, 201708.22.0)

kitchen create
-----> Starting Kitchen (v1.17.0)
-----> Creating …
Bringing machine ‘default’ up with ‘virtualbox’ provider…
==> default: Importing base box ‘bento/centos-7.3’…
==> default: Matching MAC address for NAT networking…
==> default: Checking if box ‘bento/centos-7.3’ is up to date…
==> default: Setting the name of the VM: default-centos-73_default_1506510670193_9887
==> default: Clearing any previously set network interfaces…
==> default: Preparing network interfaces based on configuration…
default: Adapter 1: nat
==> default: Forwarding ports…
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM…
==> default: Waiting for machine to boot. This may take a few minutes…
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection aborted. Retrying…
default: Warning: Remote connection disconnect. Retrying…
default: Warning: Connection aborted. Retrying…
default: Warning: Connection reset. Retrying…
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest…
default: Removing insecure key from the guest if it’s present…
default: Key inserted! Disconnecting and reconnecting using new SSH key…
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM…
==> default: Setting hostname…
==> default: Mounting shared folders…
default: /tmp/omnibus/cache => C:/Users/kgshmtest/.kitchen/cache
==> default: Machine not provisioned because --no-provision is specified.
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds
:paranoid is deprecated, please use :verify_host_key. Supported values are exactly the same, only the name of the option has changed.
Waiting for SSH service on 127.0.0.1:2222, retrying in 3 seconds

SSH succeeds to the box, which kitchen is timing out on and retrying.

ssh vagrant@127.0.0.1 -p2222
Could not create directory ‘/home/kgshmtest/.ssh’.
The authenticity of host ‘[127.0.0.1]:2222 ([127.0.0.1]:2222)’ can’t be established.
ECDSA key fingerprint is SHA256:dTd/vsmPTbrA3kPeIfArZMFEgfdlgjGHwMgE3Z5BgBc.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/home/kgshmtest/.ssh/known_hosts).
vagrant@127.0.0.1’s password:
[vagrant@default-centos-73 ~] hostname default-centos-73.vagrantup.com [vagrant@default-centos-73 ~]

You’ll definitely want to update to ChefDK 2.3.4 - there was an upstream change in net-ssh that produces those warnings and that has been resolved.

upgraded to chefDK 2.3.4, the paranoid warnings are gone but the ssh timeout errors still remain.
what else to try?

I have found a workaround after noticing that only the private key ssh authentication doesn’t work with test kitchen. I also tested by providing the whole path of private_key as parameter ssh_key in the yml file.
Later I removed it and I tested and provided username, port and password and the test instance came up with no errors. So we can safely conclude that username authentication is working fine but ssh authentication is not.

transport:
username: vagrant
port: 2222
password: vagrant