Search code examples
vagrantvirtual-machinevagrantfile

copy file from host to vagrant virtual machine


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?


Solution

  • To copy a file from the host to vagrant:

    scp -P 2222 /path/to/file vagrant@127.0.0.1:.
    
    • By default The vagrant instance uses port 2222 and ip 127.0.0.1. The password for vagrant is 'vagrant'. The file will be copied to the home of vagrant.

    To copy a file from vagrant to host machine:

    scp -P 2222 vagrant@127.0.0.1:/path/to/file