LoginSignup
0
0

More than 5 years have passed since last update.

初回 vagrant up でリトライアウト

Posted at

初回の vagrant up で延々と Authentication failure. Retrying... が発生し、リトライアウトしてしまうというネタの1バリエーションです。環境は以下の通り。

  • Host OS : Windows10
  • SSH Client : PuTTY
  • Vagrant : 1.8.5
  • VirtualBox : 5.0.26
  • Guest OS : CentOS 7.x(bento/centos-7.1)

事象

エラー
D:\> mkdir laravel
D:\> cd laravel
D:\laravel> vagrant init
(作られた Vagrantfile をエディタで修正)
D:\laravel> diff.exe Vagrantfile.orig Vagrantfile
15c15
<   config.vm.box = "base"
---
>   config.vm.box = "bento/centos-7.1"
D:\laravel> vagrant up
(中略)
    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: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
  (これを30回ほど繰り返す)
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-config で接続パラメータを確認します。

PS D:\laravel> vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile D:/laravel/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

PuTTY では OpenSSH 互換キーが使えないので、PuTTYgen.exe で private_key をインポートし、hoge.ppk を作成して秘密鍵として指定します。その後、PuTTY で vagrant@127.0.0.1:2222 に接続しようとすると、Server refused our key と怒られて、パスワード認証にフォールバックしました。

Using username "vagrant".
Server refused our key
vagrant@127.0.0.1's password:

パスワード "vagrant" でログインします。

やっぱり鍵のペアがおかしいのかなと思って作りなおしたりしていましたが、鍵の設置のため、何気に ~/.ssh を確認すると、なんと authorized_keys のパーミッションが誤っていたのを発見。即修正しました。

[vagrant@localhost ~]$ cd .ssh
[vagrant@localhost .ssh]$ ls -l
-rw-rw-r--. 1 vagrant vagrant 389 Aug 18 05:42 authorized_keys
[vagrant@localhost .ssh]$ chmod 600 authorized_keys
[vagrant@localhost .ssh]$ ls -l
-rw-------. 1 vagrant vagrant 389 Aug 18 05:42 authorized_keys

今回のケースでは、結果的にこれだけで接続できました。念のため、いったん box を消してからやり直してみても上記手順でうまくいくので、自動作成される private_key は有効のようでした。

0
0
2

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
0
0