geeks geeks - 1 month ago 8
Linux Question

How to copy file from a Vagrant machine to local host

I want to copy a local file from a Vagrant machine to my local host, 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 vagrant@127.0.0.1:/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.

Answer

You need to read the manual page for scp. The correct syntax is:

scp -P 2222 vagrant@127.0.0.1:/home/vagrant/devstack/local.conf .

The uppercase P is for "port".