Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy file from a Vagrant machine to localhost

Tags:

linux

scp

vagrant

I want to copy a local file from a Vagrant machine to my localhost, but I am getting an error message:

ssh: connect to host 127.0.0.1 port 22: Connection refused.

[user@localhost ceil]$ scp -p 2222 [email protected]:/home/vagrant/devstack/local.conf . cp: cannot stat ‘2222’: No such file or directory ssh: connect to host 127.0.0.1 port 22: Connection refused 

I also tried using using localhost but still got the same error.

like image 425
geeks Avatar asked Sep 05 '15 06:09

geeks


People also ask

What is Vagrantfile file?

A Vagrantfile is a Ruby file that instructs Vagrant to create, depending on how it is executed, new Vagrant machines or boxes. You can see a box as a compiled Vagrantfile. It describes a type of Vagrant machines. From a box, we can create new Vagrant machines.


1 Answers

Another option is cat the files to something local:

vagrant ssh -c "sudo cat /home/vagrant/devstack/local.conf" > local.conf 

This should also work for files that require root permissions (something the vagrant SCP plugin doesn't seem to support).

like image 142
Jace Browning Avatar answered Sep 28 '22 22:09

Jace Browning