cheka.jp 超不定期で更新する写真達。お口直しにどうぞ。

vagrant upでAuthentication failureと怒られた時の話

vagrantの認証エラー

新しくbox追加してvagrant upしたら認証エラーになりました。
色々情報はあるけど、どれをやっても解消しないので諦めて自力で調べてみました。

==> xxx: Waiting for machine to boot. This may take a few minutes...
    xxx: SSH address: 127.0.0.1:2200
    xxx: SSH username: vagrant
    xxx: SSH auth method: private key
    xxx: Warning: Remote connection disconnect. Retrying...
    xxx: Warning: Authentication failure. Retrying...
    xxx: Warning: Authentication failure. Retrying...
    xxx: Warning: Authentication failure. Retrying...
    xxx 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.

vagrant sshでログインできるか?

パスワード確認でログインできた方は鍵の情報を更新するとエラーが解消されます。
ログインできない方は別のエラーなのでスルーしてください。

パスワードは「vagrant」です。

$ vagrant ssh
$ vagrant@127.0.0.1's password:

Vagrantfileが存在するディレクトリにてsshの情報を確認する

$ vagrant ssh-config

IdentityFileの箇所が鍵の場所です。
既に別のvagrant環境で使われている場合は、正しくログインできるvagrant環境の鍵をコピペしましょう。
鍵情報は、
/home/vagrant/.ssh/authorized_keys
に記載されています。

新規の場合はエラーにならないと思いますが、もしエラーになった場合はssh-keygenで新規に作成してください。
*この場合はIdentityFileの置き換えも必要になります。

新しい鍵の設定を行う

$ cd /home/vagrant/.ssh
$ mv authorized_keys authorized_keys.bk
$ vi authorized_keys
> xxxxx 鍵情報を入力
$ chmod 644 authorized_keys

リロードして確認してみます。

$ vagrant reload

無事起動できました。