Skip to content

vagrant up でAuthentication failure. Retrying...

kteraguchi edited this page Dec 15, 2015 · 1 revision

https://github.com/NetCommons3/NetCommons3/wiki/VagrantとVBoxの関係が切れた

の関連で、またエラーになりました。

vagrant up を実行すると

>vagrant up default
========= 省略 =========
==> 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: Connection timeout. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
========= 省略(30回くらい繰り返します。しかも1回の時間が長い。。。) =========
    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 haltすると

>vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if capable.
==> default: Forcing shutdown of VM...
>

調べると、どうやら、鍵のペアがそろってないっポイ。
秘密鍵:ホストOSのNC3ディレクトリ/.vagrant/machines/default/virtualbox/private_key
公開鍵:ゲストOSのvagrantユーザホームディレクトリ(/home/vagrant)/.ssh/authorized_keys

調べながら色々やってみたところ、 http://ri.hateblo.jp/entry/2014/06/03/021234 が参考になりました。

手順

  • ホストOSのNC3ディレクトリ/.vagrant/machines/default/virtualbox/private_keyを削除します。
  • vagrant up を実行します。 Authentication failure. Retrying...が発生するが無視。
  • sshはつながるので、sshでログインします。
  • ゲストOSのvagrantユーザホームディレクトリ(/home/vagrant)/.ssh/authorized_keysの中身を、 https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub の内容に書き換えます。
  • ホストOSからvagrant haltを実行します。
>vagrant halt
==> default: Attempting graceful shutdown of VM...
    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...
>

鍵が再作成されるので、vagrant upで問題なく起動します。

公開鍵だけ書き換えたり、秘密鍵だけ削除したり試してみたのですが、 上記の手順でやらないと、再作成されませんでした。

vagrant up時に
ホストOSのユーザホームディレクトリ(windowsだとC:\Users\ユーザー名)/.vagrant.d/insecure_private_key
で認証させとかないといけないっポイです。
(ホストOSのNC3ディレクトリ/.vagrant/machines/default/virtualbox/private_key
 がないとホストOSのユーザホームディレクトリ(windowsだとC:\Users\ユーザー名)/.vagrant.d/insecure_private_key
 を使うっポイです。)
妄想です。正しい情報あれば欲しいです。

Clone this wiki locally