Reputation: 1306
I am new with virtual machine. I want to copy a file from host (Mac) to vagrant virtual machine. I could not share a folder, so I want to use command line. How can I copy a file from host to vagrant virtual machine with command line?
Upvotes: 8
Views: 8287
Reputation: 48943
There is an officially supported command vagrant upload:
vagrant upload source [destination] [name|id]
Upvotes: 4
Reputation: 1099
To copy a file from the host to vagrant:
scp -P 2222 /path/to/file [email protected]:.
To copy a file from vagrant to host machine:
scp -P 2222 [email protected]:/path/to/file
Upvotes: 9
Reputation: 53813
one easy way is to let vagrant handles the copy through the File Provisioner :
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
If you really want to use a command line, it might be dependant on your VM, assuming you have linux based VM, you could use scp and copy the file through ssh. see https://unix.stackexchange.com/a/106482
Upvotes: 4