Vagrant with CentOS

I got an issue with vagrant running CentOS as testing environment:

$ kitchen create
-----> Starting Kitchen (v1.11.1)
-----> Creating <docker-centos72>...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'bento/centos-7.2' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'bento/centos-7.2'
default: URL: https://atlas.hashicorp.com/bento/centos-7.2
==> default: Adding box 'bento/centos-7.2' (v2.2.9) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/bento/boxes/centos-7.2/versions/2.2.9/providers/virtualbox.box
default:
==> default: Successfully added box 'bento/centos-7.2' (v2.2.9) for 'virtualbox'!
==> default: Preparing master VM for linked clones...
default: This is a one time operation. Once the master VM is prepared,
default: it will be used as a base for linked clones, making the creation
default: of new VMs take milliseconds on a modern system.
==> default: Importing base box 'bento/centos-7.2'...
==> default: Cloning VM...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7.2' is up to date...
==> default: Setting the name of the VM: kitchen-cookbook-didata-tfs-docker-centos72_default_1474595118050_22387
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> 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: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. 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: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...

“kitchen create” is a part of kitchen, which is triggering the vagrant to create a VM by using Virtualbox.

The VM was created successfully but we are not able to connect to it with SSH due to the error message:

default: Warning: Authentication failure. Retrying...

I tested Ubuntu image, it’s working OK, only for CentOS got issue at the moment.

I’m sure that I remembered that it was working fine before, so I believe this is the issue from vagrant…

By checking the source code for vagrant, this changeset “4aaa600” shows that “chmod 600 ~/.ssh/authorized_keys” is removed from def “self.remove_public_key”.

Manually adding this to:

Windows: C:\HashiCorp\vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb

Then check it again:

$ kitchen create
-----> Starting Kitchen (v1.11.1)
-----> Creating <docker-centos72>...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Cloning VM...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/centos-7.2' is up to date...
==> default: Setting the name of the VM: kitchen-cookbook-didata-tfs-docker-centos72_default_1474603585550_53027
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 (guest) => 2200 (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:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. 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: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.26
default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /tmp/chef-client => C:/River/vagrant_shares/chef-client
[SSH] Established
Vagrant instance <docker-centos72> created.
Finished creating <docker-centos72> (1m10.54s).
-----> Kitchen is finished. (1m15.43s)

I’m not using OS X so I cannot tell, sorry.

Thanks

River

Like what you read? Give River Yang a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.