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:
    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.



MBA:MyCentOS hoge$ vagrant ssh-config
Host default

  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




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`.



vagrant status

実際には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
[vagrant@localhost ~]$