LoginSignup
60
60

More than 5 years have passed since last update.

Vagrant vagrant upしたときに"Authentication failure. Retrying..."警告がでてvagrant sshできない状態からの脱出

Posted at

遭遇した問題

なぜかvagrant upをすると以下のような警告

$ 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: Forwarding ports...
    default: 22 => 2222 (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: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...

仮想マシンの起動自体はできていて、sshの鍵認証に失敗している模様

$ vagrant ssh
vagrant@127.0.0.1's password:

をするとパスワードを求められてしまう

解決策

半日くらい悩んで、
仮想マシン側の/home/vagrantのパーミッションが不適切なのが原因だと判明
これは別にVagrantに限った問題ではなく、sshの仕様のせい。
仮想マシンなので悪びれることもなくおっぴろげの777にしていたことを反省。

vagrantだとデフォルトのパスワードが"vagrant"なので、
パスワードログインしてパーミッションを755に変更して解決

大事なこと

公開鍵認証の仕様でパーミッションが適切で無いとエラーになる
1. 接続先ホームディレクトリは700 or 711 or 755
2. 接続元は.sshは700, .ssh/id_rsa(秘密鍵)は600

2はこれまでも遭遇していたが、1に関しては今回初めて知った。
2と違ってエラーが明示されないので苦戦した。

参考

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