mikebronner's avatar

Vagrant Error - Can't Read SSH Key

I just reinstalled OS X from scratch on my mac, and copied over all my data files (not a Time Machine restore). When trying to run vagrant up I now get this:

[...]/homestead/scripts/homestead.rb:26:in `read': No such file or directory - ~/.ssh/id_rsa.pub (Errno::ENOENT)

I regenerated my ssh keys and tested them on GitHub, so they do work. I also ran cat ~/.ssh/id_rsa.pub which output the file without any problems, so it does exist. Any ideas what might be happening here?

0 likes
16 replies
PratyushPundir's avatar

Hey, have you made changes to homestead.yaml to reflect the correct path to your SSH key? The correct path should be something like :

/Users/YOUR_USERNAME/.ssh/id_rsa.pub

since you have a fresh install, you may have missed doing that.

mikebronner's avatar
mikebronner
OP
Best Answer
Level 16

OK, found the problem: apparently I had an OLD version of homestead on my machine, and updating the homestead.rb file fixed the problem.

mikebronner's avatar

Using ~ to indicate your home directory is a better approach and will work in teams. Although not sure how it will work on windows -- if homestead can even be installed on Windows?

PratyushPundir's avatar

I agree strongly with @mikebronner. Using ~/ to refer to your home folder is definitely the way to go for Team Devs. Great to be aware of the issue and it's fix.

xingfucoder's avatar

Hi @mikebronner I installed on a Windows PC and the unique issue that I had the VirtualBox issue that I commented here some days ago.

It was fixed with the test version installed.

If you have a problem with your keys you may generate those using the cmd command as follow:

ssh-keygen -t rsa -C "your@email.com"

And then you need to reference the full path to this folder, if I don't remember bad:

C:/users/[your_username]/.ssh/id_rsa.pub

Hope it helps you.

1 like
mikebronner's avatar

Thanks @codeatbusiness, good to know for the windows users out there. I guess they will be out of luck in a team environment. :) I guess if its a pure windows team, they could use something like:

%USERPROFILE%/.ssh/id_rsa.pub

However, was just reading that Ruby will interpret the "~" home path indicator correctly in Windows as well, so using ~/.ssh/id_rsa.pub should still work in homestead on Windows. Can someone verify?

xingfucoder's avatar

Yeah @mikebronner, I was searching about a mask for the user path.

Another question, did you enabled Virtualization Technology in your BIOS system before install your Vagrant enviroment?

xingfucoder's avatar

Ok :) thanks I'm using a Windows 8 OS system and every installation is a headache.

xingfucoder's avatar

Yes @mikebronner, the path as you specified works fine for me.

I use the following vagrant.yaml file:

ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Desktop/code/
      to: /home/vagrant/code/

sites:
    - map: project.app:8000
      to: /home/vagrant/code/Project/public

variables:
    - key: APP_ENV
      value: local

Hope it helps you.

1 like

Please or to participate in this conversation.