Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 964
Mehdi Avatar asked Dec 01 '17 19:12

Mehdi


People also ask

How do I copy files to VirtualBox?

Transfer Files From Host To VirtualBox Using A USB stickInsert the USB device you wish to use. Launch VirtualBox and click File > Preferences, then Extensions and click +. Browse to the downloaded Extension Pack, click Open, then when prompted, Install. Follow the prompts to complete the process.

How do I transfer files from vagrant to local?

Essentially, cp [file] /var/www/[your vm]/. vagrant will copy the file to the . vagrant folder at your project root, where you can see and move the file in your desktop OS.


1 Answers

To copy a file from the host to vagrant:

scp -P 2222 /path/to/file [email protected]:.
  • 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 [email protected]:/path/to/file
like image 74
aprasanth Avatar answered Sep 23 '22 00:09

aprasanth