Easiest way to copy a single file from host to Vagrant guest?

前端 未结 19 1615
暖寄归人
暖寄归人 2020-12-22 15:15

I have a use case where I occasionally want to copy a single file from my host machine to the Vagrant guest.

I don\'t want to do so via traditional provisioners (Pup

19条回答
  •  囚心锁ツ
    2020-12-22 15:17

    As default, the first vagrant instance use ssh port as 2222, and its ip address is 127.0.0.1 (You may need adjust the port with real virtual host)

    ==> default: Forwarding ports...
        default: 22 (guest) => 2222 (host) (adapter 1)
    

    So you can run below command to copy your local file to vagrant instance. password is the same as username which is vagrant.

    scp -P 2222 your_file vagrant@127.0.0.1:.
    

    You can also copy the file back to your local host.

    scp -P 2222 vagrant@127.0.0.1:/PATH/filename .
    

提交回复
热议问题