Reputation: 3223
Can I retrieve the files from my vagrant machine (guest) and sync it to my host machine?
I know sync folders work the other way around but I was hoping there is a way to make it in reverse? Instead of synching files from the host machine to the guest machine; retrieve the files from inside the guest machine and have it exposed on the host machine.
Thanks.
Upvotes: 9
Views: 5001
Reputation: 125
Using scp with private key will make this much easy!
scp -i ./.vagrant/machines/default/virtualbox/private_key -r -P2222 [email protected]:/home/vagrant/somefolder ./
Upvotes: 3
Reputation: 1124
Install python then run, e.g.
$ nohup python3.6 -m SimpleHTTPServer &
in the output directory. I put this command in a file set to run always during provisioning. This solution required zero system configuration.
Upvotes: 1
Reputation: 107
Why not just put them in the /vagrant folder of your vagrant vm. This is a special mounted folder from the host (where Vagrantfile) resides to the guest.
This way you do not have to worry about doing any other copy operations between hosts.
$ ls
Vagrantfile
$ vagrant ssh
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-42-generic x86_64)
Last login: Wed Oct 12 12:05:53 2016 from 10.0.2.2
vagrant@vagrant-virtualbox:~$ ls /vagrant
Vagrantfile
vagrant@vagrant-virtualbox:~$ cd /vagrant
vagrant@vagrant-virtualbox:/vagrant$ touch hello
vagrant@vagrant-virtualbox:/vagrant$ exit
logout
Connection to 127.0.0.1 closed.
$ ls
Vagrantfile hello
$
Upvotes: 9
Reputation: 426
have you tried to scp files between your host and your virtual machine ? As I remember, the ssh login and password are "vagrant".
Something like this could do the job :
scp vagrant@<vm_ip>:<path_to_file> <path_to_dest_on_your_host>
Upvotes: 5