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

前端 未结 19 1777
暖寄归人
暖寄归人 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:29

    if for some reasons you don't have permission to use

    vagrant plugin install vagrant-scp
    

    there is an alternative way :

    First vagrant up yourVagrantProject, then write in the terminal :

    vagrant ssh-config
    

    you will have informations about "HostName" and "Port" of your virtual machine.

    In some case, you could have some virtual machines in your project. So just find your master-machine (in general, this VM has the port 2222 ), and don't pay attention to others machines informations.

    write the command to make the copy :

    scp -P xxPortxx  /Users/where/is/your/file.txt  vagrant@xxHostNamexx:/home/vagrant
    

    At this steep you will have to put a vagrant password : by default it's "vagrant"

    after that if you look at files in your virtual machine:

    vagrant ssh xxVirtualMachineNamexx
    pwd
    ls
    

    you will have the "file.txt" in your virtual machine directory

提交回复
热议问题