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

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

    Here is my approach to the problem:

    Step 1 - Find the private key, ssh port and IP:

    root@vivi:/opt/boxes/jessie# vagrant ssh-config
    Host default
      HostName 127.0.0.1
      User vagrant
      Port 2222
      UserKnownHostsFile /dev/null
      StrictHostKeyChecking no
      PasswordAuthentication no
      IdentityFile /root/.vagrant.d/insecure_private_key
      IdentitiesOnly yes
      LogLevel FATAL
    

    Step 2 - Transfer file using the port and private key as parameters for scp:

      scp -P 2222 -i /root/.vagrant.d/insecure_private_key \
      someFileName.txt vagrant@127.0.0.1:~
    

    I hope it helps,

提交回复
热议问题