-1

Lets say I'm running an instance of a box. How to include a file that physically resides in the same directory as box and vagrantfile? I suppose I need to state that in the vagrantfile. How should that include look?

My vagrantfile (excluding the comments) is:

Vagrant.configure("2") do |config|
config.vm.synced_folder ".", "/vagrant_data"

Running the box I get:

(...)
default: SSH auth method: private key
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...

I can 'vagrant ssh' into it, but theres no /vagrant_data folder available

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
kol23
  • 1,498
  • 3
  • 16
  • 35

1 Answers1

0

From vagrant doc

By default, Vagrant shares your project directory (remember, that is the one with the Vagrantfile) to the /vagrant directory in your guest machine.

Note that when you vagrant ssh into your machine, you're in /home/vagrant. /home/vagrant is a different directory from the synced /vagrant directory.

so if you have a file that physically resides in the same directory as vagrantfile you will be able to access in the VM from the /vagrant directory.

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
  • vagrant ssh with ls /vagrant shows no files included. However, when I run vagrant up I'm receiving authentication failure – kol23 Sep 11 '17 at 11:34
  • _I'm receiving authentication failure_ ? but you can connect ? it might mean the `/vagrant` folder from the box (some box owner do disable) you can add the following line in your Vagrantfile `config.vm.synced_folder ".", "/vagrant", disabled: false` if you want to have the default `/vagrant` folder back or replace `/vagrant` by any other name. – Frederic Henri Sep 11 '17 at 11:49
  • yes I can run vagrant ssh and connect into the running machine. Still nothing found with ls /vagrant. I also inserted that line you mentioned. – kol23 Sep 11 '17 at 12:43
  • add `config.vm.synced_folder ".", "/vagrant_data"` and restart the VM by running `vagrant reload` files should be in `/vagrant_data` directory – Frederic Henri Sep 11 '17 at 12:52
  • I did that but there is no directory /vagrant_data created. When trying to perform vagrant reload I get: default: SSH auth method: private key default: Warning: Authentication failure. Retrying... – kol23 Sep 14 '17 at 06:37
  • can you edit your initial question with your Vagrantfile and the output of `vagrant up` – Frederic Henri Sep 14 '17 at 07:22