How do I associate a Vagrant project directory with an existing VirtualBox VM?

后端 未结 10 1800
梦如初夏
梦如初夏 2020-12-02 03:57

Somehow my Vagrant project has disassociated itself from its VirtualBox VM, so that when I vagrant up Vagrant will import the base-box and create a new virtual

10条回答
  •  既然无缘
    2020-12-02 04:21

    Had the issue today, my .vagrant folder was missing and found that there was a few more steps than simply setting the id:

    1. Set the id:

      VBoxManage list vms
      

      Find the id and set in {project-folder}/.vagrant/machines/default/virtualbox/id.

      Note that default may be different if set in your Vagrantfile e.g. config.vm.define "someothername".

    2. Stop the machine from provisioning:

      Create a file named action_provision in the same dir as the id file, set it's contents to: 1.5:{id} replacing {id} with the id found in step 1.

    3. Setup a new public/private key:

      Vagrant uses a private key stored in .vagrant/machines/default/virtualbox/private_key to ssh into the machine. You'll need to generate a new one.

      ssh-keygen -t rsa
      

      name it private_key.

      vagrant ssh then copy the private_key.pub into /home/vagrant/.ssh/authorized_keys.

提交回复
热议问题