1

I want to copy local.conf from local vagrant machine to local system(my machine). Vagrant is running on the same machine. I tried the following command. It run successfully, but when I search local.conf file on my system I get nothing.

[vagrant@localhost devstack]$ scp vagrant@192.168.50.4:/home/vagrant/local.conf local.conf 
vagrant@192.168.50.4's password: 
local.conf                                              100% 3857     3.8KB/s   00:00    
[vagrant@localhost devstack]$ 
geeks
  • 2,025
  • 6
  • 31
  • 49

3 Answers3

4

To copy files from host to vm (and vice versa) you do not necessarily need specific protocol like scope or ftp.

By default vagrant automatically makes a /vagrant directory a shared folder with your local folder. so you can just copy any files from the vm into the /vagrant directory and you will see them under your local folder where you have the Vagrantfile and where you initialized vagrant.

And if you have other files located on your local hard drive that you want to share with your vm, you can easily add a shared folder from the Vagrantfile

  config.vm.synced_folder "/Users/fhenri/myproject", "/project"

will shared the local folder /Users/fhenri/myproject with the /project folder from the vm and you can just use mv or cp to move / copy files from one to another

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
2

You need to specify on which machine you run your command. Your command is basically correct, but you need to run it on your local host, not on vagrant machine. In example, you can think of two hosts, local and vagrant:

[local]$ scp vagrant@vagrant:/home/vagrant/local.conf local.conf 
vagrant@vagrant's password: 
local.conf                                      100% 3857     3.8KB/s   00:00    

Trying ls in the same directory should show you your required file:

[local]$ ls local.conf
Jakuje
  • 24,773
  • 12
  • 69
  • 75
0

for example:

"sudo scp -P 2222 vagrant@127.0.0.1:/home/vagrant/dumpfilename.sql /home/ "