0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Vagrant] Warning: Authentication failure. Retrying...

Last updated at Posted at 2016-09-30

vagrantのソフトウェアをアップデートしたら、ワーニングが発生するようになった。
vagrantのゲストOS自体は立ち上がっているが、SSH接続がパスワード認証が必要であったり、Webサイトの一部が見れない状態になった。

以下、原因と対処法。

原因

vagrant upした際に生成される秘密鍵と、ゲストOSに設定してある公開鍵がマッチしないため。

対処法

秘密鍵を確認

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/******/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL

公開鍵を生成

$ ssh-keygen -yf /Users/******/.vagrant/machines/default/virtualbox/private_key > ./public_key

カレントディレクトリにファイルを書き出す。

ゲストOSに生成した公開鍵を設定する

$ vagrant ssh
vagrant@127.0.0.1's password: 
Last login: Thu Sep  8 12:15:20 2016 from 10.0.2.2
[vagrant@centos ~]$ vi ./.ssh/authorized_keys 
[vagrant@centos ~]$ sudo chmod 700 ~/.ssh
[vagrant@centos ~]$ sudo chmod 600 ~/.ssh/authorized_keys

./public_keyの内容をコピペする。改行が入らないように注意する。

確認

vagrantを立ち上げ直してワーニングがは発生していないことを確認する。

$ vagrant halt                                                                                                                    
==> default: Attempting graceful shutdown of VM...

$ vagrant up      
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
GuestAdditions 4.3.34 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/masaakieda/Development/myproject/plusstyle
    default: /var/www/html => /Users/masaakieda/Development/myproject/plusstyle/www
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

参考

Package化したboxを使うときによく出るエラー

0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?