112

I could not figure out where I made a mistake here. My command vagrant up replies with the following lines

$ vagrant up
Check your Homestead.yaml file, the path to your private key does not exist.
Check your Homestead.yaml file, the path to your private key does not exist.

enter image description here

Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
Mitesh
  • 1,544
  • 3
  • 13
  • 26

4 Answers4

218

You want to follow these steps from terminal

Generate a ssh key ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Start ssh agent eval "$(ssh-agent -s)"

Add your SSH private key to the ssh-agent ssh-add -k ~/.ssh/id_rsa

Then run vagrant up

Rui Carneiro
  • 5,595
  • 5
  • 33
  • 39
prola
  • 2,793
  • 1
  • 16
  • 15
  • 1
    Small edit: should have been a small 'k' in ssh-add options (`ssh-add -k ~/.ssh/id_rsa`) – Poh Zi How Jul 16 '17 at 05:04
  • 3
    Enter file in which to save the key (/c/Users/SpiderMan/.ssh/id_rsa): id_rsa and than you'll find id_rsa named file in your Home, put in to .ssh folder. – Yevgeniy Afanasyev Aug 05 '17 at 07:16
  • 14
    For me, running only the first command, and then doing `vagrant up` worked. – Ciberman Sep 20 '17 at 16:47
  • 1
    @AlexandraDamaschin It depends on the environment either in Apple - Terminal or Windows - CMD – prola May 17 '18 at 17:42
  • 1
    Worx like a charm. For the record, ran this from GitBash on Windows. – skidadon Aug 03 '18 at 04:59
  • I'm mac user, tried 'ss-add -k ~/.ssh/id_rsa' and the message was "/Users/gustavosevero/.ssh/id_rsa: No such file or directory" – GustavoSevero Nov 22 '18 at 20:48
  • You mister is a life savior – Lucas M. Oliveira Apr 19 '19 at 21:45
  • Steps 2 and 3 were unnecessary for me. Step 1 prompts for a file name and a passphrase. It saves two files named `your-file-name` which I accidentally saved in Homestead folder. Just move those files to `~/.ssh` if they're not already there and then go to Homestead.yaml and change `authorize:` to `~/.ssh/your-file-name.pub` and `keys:` to `- ~.ssh/your-file-name`. After that ´vagrant up` works as intended. – s3c Aug 10 '20 at 07:01
55

You don't need to generate a key. Simply run this:

# touch ~/.ssh/id_rsa

Then

# vagrant up

Jake Wilson
  • 88,616
  • 93
  • 252
  • 370
  • Wouldn't it be better off just generating the key for future use? – brianforan Feb 26 '18 at 18:55
  • 3
    It certainly would be good to do, but it's not a hard requirement of getting vagrant running. The file simply needs to exist. – Jake Wilson Feb 27 '18 at 06:24
  • 3
    or (windows) just create an empty file at c:/users//.ssh/id_rsa – Ken May 03 '18 at 16:58
  • @Ken that is exactly what `touch` does. – Jake Wilson May 04 '18 at 05:29
  • 3
    @JakeWilson I know, but touch does not work on windows. At least not on my machine. – Ken May 04 '18 at 08:39
  • This is the best solution as it's so simple. For those on Windows, touch just creates the file so you could just create a blank file. – Paul Feakins Jan 02 '19 at 20:56
  • Not that I use Winblows anymore , but the comment for Windows could/should have been "Start - Run - type cmd , paste this command into the prompt `mkdir %userprofile/.ssh/ && type nul > %userprofile%/.ssh/id_rsa` – Yordan Georgiev Nov 07 '19 at 12:29
  • On macOS Monterey, in case of getting the following error: `/Users/username/.ssh/id_rsa: No such file or directory` do it in the following two commands: `# mkdir ~/.ssh` `# touch ~/.ssh/id_rsa` – Muhammad Abu ul Fazal Feb 18 '22 at 03:54
32

For Windows users, you can use PuTTYgen to generate public/private key pair. Then save the public key as mypublickey.pub. and private key as myprivatekey.ppk.

In homestead.yaml change to the following:

authorize: C:\Users\YOUR_USERNAME\.ssh\mykey.pub

keys:
    - C:\Users\YOUR_USERNAME\.ssh\myprivatekey.ppk
Ahmad.Net
  • 581
  • 5
  • 8
  • I think your better of when you put the file in your project directory. That way, you can pass your project to some other user, without having to regenerate the key-files, or editing the file location in the config. Of coure you delete the file when you are switching to production. – qvotaxon Aug 31 '18 at 08:51
2

You can also use git bash to generate SSH keys automatically for windows

ottz0
  • 2,595
  • 7
  • 25
  • 45