LoginSignup
17
13

More than 5 years have passed since last update.

Vagrant v1.8.5でvagrant upすると、エラー(Timed out while waiting for the machine to boot...)が出てきて進まない

Posted at

環境

  • ホストOS: Xubuntu16.04.1(ただしOS関係なく起きる模様)
  • ゲストOS: CentOS7
  • Vagrant: 1.8.5(これが主な原因)
  • VirtualBox: 5.1
$vagrant up
ほげほげ(省略)
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...

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.

と出てきて何度もvagrant upしてもおないことが起きたのでメモ。

原因

vagrant 1.8.5 におけるバグ。
https://github.com/mitchellh/vagrant/issues/7610
要はvagrantで作った鍵の権限の設定ミスでログインできないっぽい。
1.8.6では対策されそう。

対策

1.8.5におけるバグなので、1.8.4に下げればいいやと思ったが、1.8.4に下げるとVirtualBox5.1には対応していないので、Virtualboxもバージョン下げないといけない・・・。
それはめんどくさいので、Issueページに書いてある対策を実行した。

方法1 public_key.rb書き換え

Windowsの場合
C:\HashiCorp\vagrant\embedded\gems\gems\vagrant-1.8.5\plugins\guests\linux\cap\public_key.rb
Linux/macOS(OS X)の場合
/opt/vagrant/embedded/gems/gems/vagrant-1.8.5/plugins/guests/linux/cap/public_key.rb
に、以下の+マークの行を追記する。

@@ -54,6 +54,7 @@
             if test -f ~/.ssh/authorized_keys; then
               grep -v -x -f '#{remote_path}' ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.tmp
               mv ~/.ssh/authorized_keys.tmp ~/.ssh/authorized_keys
+              chmod 0600 ~/.ssh/authorized_keys
             fi

             rm -f '#{remote_path}'

これで一旦VMを消して実行すれば大丈夫。

方法2 ゲストOSの権限を変える

もうこれについては記事が上がっているので省略。
既存のVMはこれでやれば消さなくていいのでいいかも。
http://qiita.com/ritukiii/items/9a51adc0334132bc8e15

方法3 VagrantFileを書き換え

VagrantFile
config.ssh.insert_key = false

を追記。ただこれで直るかは試していません・・・。

まとめ

Vagrantめんどくさいなぁと思えるバグでした。バージョンには注意を払いつつ使いましょう。
質問するときも環境開示する大切さがわかってもらえると嬉しいです。

17
13
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
13