Vagrant: copy from/to guest to/from local
At first, you need to install two plugins
To do it you need to install vagrant-scp
plugin. But it depends on vagrant-vbguest
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-scp
Use
vagrant global-status
to find out the id or name of the guest VM.
I prefer to use id, because if haven't changed a name of the VM it will be default
for all your VMs. But id is unique.
The output will looks like
id name provider state directory
----------------------------------------------------------------------------------------
<FIRST VM ID> default virtualbox running <FIRST VM HOST FOLDER PATH>
<SECOND VM ID> default virtualbox poweroff <SECOND VM HOST FOLDER PATH>
To copy from guest to host
Execute command on your host
vagrant scp <VM ID>:<GUEST VM PATH> <HOST PATH>
For example
vagrant scp 1c5345f:~/.bashrc .
To copy from host to guest
Execute command on your host
vagrant scp <VM ID>:<GUEST VM PATH> <HOST PATH>
vagrant scp <HOST PATH> <VM ID>:<GUEST VM PATH>
For example
vagrant scp 1c5345f:~/.bashrc .
vagrant scp ~/.oh-my-zsh/oh-my-zsh.sh 1c5345f:~/.oh-my-zsh/