vagrant upでprivate keyより先に進まない症状(10/25追記あり)

環境

OS X / VirtualBox 5.1.8 / Vagrant 1.8.5

エラー

vagrant up を実行すると次のような状態で停止する。

MBA:MyCentOS hoge$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'bento/centos-6.8' is up to date...
==> default: Resuming suspended VM...
==> 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

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.

Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly,you may want to increase
the timeout ("config.vm.boot_timeout") value.

対処法

どうやらSSH鍵関連の問題でログインできないらしい。
秘密鍵に対応した公開鍵の作成が目標。
Vagrantが照会している鍵の場所を確認。

MBA:MyCentOS hoge$ vagrant ssh-config
Host default

  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/hoge/.vagrant.d/insecure_private_key
  IdentitiesOnly yes

  LogLevel FATAL

これで秘密鍵の場所(IdentityFile /Users/hoge/.vagrant.d/insecure_private_key)が分かったので、この秘密鍵から公開鍵を作成する。

MBA:~ hoge$ ssh-keygen -yf /Users/hoge/.vagrant.d/insecure_private_key > public_key

作成した公開鍵の中身

/Users/hoge/MyVagrant

に張り付け。

emacs public_key
公開鍵をコピー

既存のVagrantfileを削除し、再びvagrant initを行いVagrantfileを作ってからvagrantを再起動。

vagrant init bento/centos-6.8
vagrant up

最後に仮想マシンが動いているか確認。

MBA:MyCentOS hoge$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
Simply run `vagrant up`.

動いた!

2016/10/25追記

vagrant status

がrunningだったので正常に動いたと勘違いしてました。
実際にはvagrant が動いているだけできちんとVirtualBoxに接続できていなかったので

cd Users/hoge/MyVagrant/
vagrant ssh-config --host hostname >> ~/.ssh/config

を行う事で直接ssh鍵を書き出した。再び、vagrant upしてvagrant sshを行う。

MBA:MyCentOS hoge$ vagrant ssh
Last login: Mon Oct 24 15:31:58 2016 from 10.0.2.2
[vagrant@localhost ~]$ 

今度こそ解決。