Vagrant起動時にprivate keyで止まる

この記事は最終更新日から5年以上経過しています。
内容が古い可能性がありますのでご注意ください。

Vagrantで仮想マシンを作ろうと思ったら躓いたので、その時のメモ。 環境は以下の通り。

  • Windows10(1903)
  • VirtualBox(6.0.10)
  • Vagrant(2.2.5)

使ったboxは bento/centos-7.4

Vagrant Cloud by HashiCorp
Vagrant Cloud by HashiCorp

初回の vagrant up で止まる

vagrant init して、初めて vagrant up したときに、private key で止まってしまう場合。 それでもひたすら待つとタイムアウトになる。

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

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.

対応その1:BIOSの設定

BIOSで Intel Virtualization Technology を有効にする。
デフォルトで有効になってることが多いらしいけど、自分のマシンは無効になってた……。

対応その2:boxのバージョンを変える

使うboxを、記事を書いた時点で最新の bento/centos-7.6 にしたら、うまくいった。 以下がその時のログ。
インストール直後は、SSHのキーがセキュアではない?ようだが、それを自動で作成し直してくれる。

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: Connection reset. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Connection aborted. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Connection reset. 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!

2回目以降の vagrant up で止まる場合

前回の終了時に vagrant suspend で終了していると、やっぱり private key で止まる。
終了するときは vagrant halt しておくと大丈夫。

この private key で止まるというトラブルはよくあることらしく、ググると大量のページがヒットする。
しかも原因がみんなまちまちで、解決方法もさらにまちまち。
なかなか厄介な問題だな……。

コメント