Saturday, May 25, 2019

Easiest way to scp files from host to Vagrant guest (or visa versa)

If you running a vagrant instance, and you forgot to set up file sharing, but *now* you need to copy a file off to a guest, or on a guest.

Here is a method, I used to save my bacon.

Try this:

vagrant plugin install vagrant-scp (From vagrant-scp)
 
And then the method is
 
vagrant scp <some_local_file_or_dir> [vm_name]:<somewhere_on_the_vm>
 
To get "vm_name" you need to run:

vagrant global-status

In my instance:

bclark@bclark:~/Vagrant_Projects/Imapproxy$ vagrant global-status
id       name         provider   state    directory                                          
--------------------------------------------------------------------------------------------- 
5250600  default      virtualbox running  /home/bclark/Vagrant_Projects/Imapproxy

Then to copy the files, I run:

vagrant scp 5250600:/etc/dovecot /path/to/where/you/want/it/stored

HTH
Brent

No comments:

Post a Comment