5

On vagrant provision of Laravel Homestead I get SSH authentication failed! and the Vagrant instance won't run.

SSH authentication failed! This is typically caused by the public/private keypair for the SSH user not being properly set on the guest VM.

This seems to have started from the error when I first provisioned homestead:

==> default: tee: /home/vagrant/.ssh/authorized_keys: No such file or directory
Rajender Joshi
  • 4,155
  • 1
  • 23
  • 39
Bradley Flood
  • 10,233
  • 3
  • 46
  • 43

2 Answers2

10

Having the default folder mapped to /home/vagrant in the Homestead.yaml was causing the issue.

This was my folders setting:

folders:
    - map: /Users/username/www
      to: /home/vagrant

Adding a folder deep fixed the problem:

    folders:
        - map: /Users/username/www/homestead
          to: /home/vagrant/www

Working :)

Perhaps someone can elaborate as to why this happens?

Bradley Flood
  • 10,233
  • 3
  • 46
  • 43
  • 3
    I believe the problem is that if you mount to just /home/vagrant, you end up overwriting the home folder of the "vagrant" user, so it wouldn't have access to any of it's files, especially the dot (.) files. So things like the .ssh directory, etc, would not be available or writable. Like if that user's home folder was wiped clean. And that user is the default user for the system, and the one the Homestead scripts tries to copy the keys to. Moving one directory down makes the home folder available while mounting your shared folder. – noeldiaz Jul 06 '14 at 02:34
0

did you set your ssh key to the correct path?

authorize: <SSH KEY PATH TO YOUR PRIVATE KEY>

keys:
    - <SSH KEY PATH TO YOUR PRIVATE KEY>

if you didnt set them right it cant connect

EDIT You should not match your project to the root folder, because it matches the Homestead repository to your /home/vagrant/ path