geeks
geeks

Reputation: 2055

How to copy file from local vagrant to local system?

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 [email protected]:/home/vagrant/local.conf local.conf 
[email protected]'s password: 
local.conf                                              100% 3857     3.8KB/s   00:00    
[vagrant@localhost devstack]$ 

Upvotes: 2

Views: 4924

Answers (3)

Mikhail Bilida
Mikhail Bilida

Reputation: 1

for example:

"sudo scp -P 2222 [email protected]:/home/vagrant/dumpfilename.sql /home/ "

Upvotes: 0

Frederic Henri
Frederic Henri

Reputation: 53813

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

Upvotes: 5

Jakuje
Jakuje

Reputation: 26016

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

Upvotes: 2

Related Questions