title: How to include and reference a custom ssh key in a vagrant base (baseline) box? (virtualbox)
body: <p>In vagrant documentation i did not found a hint on how to reference an included file from a included Vagrantfile within the same baseline box when using "vagrant package". Can anyone help?</p>
  
  <p><strong>Details:</strong></p>
  
  <p>When creating a new baseline box from scratch for vagrant, you are free to use the standard vagrant insecure ssh key or to create a custom new key. I did the last thing. And this new baseline box works fine with my custom key, when i use my Vagrantfile with this additional line:</p>
  
  <pre><code>config.ssh.private_key_path = "custom_key_file"
  </code></pre>
  
  <p>Now i decided to distribute my baseline box to my team members. Thats no problem. Just enter:</p>
  
  <pre><code>vagrant package --output custom.box
  </code></pre>
  
  <p>All other team members do copy the "custom_key_file" to the project root dir and create a "Vagrantfile" with this content (done using a version controll system):</p>
  
  <pre><code># -*- mode: ruby -*-
  # vi: set ft=ruby :
  
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
  VAGRANTFILE_API_VERSION = "2"
  
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config.vm.box = "custombox"
      config.ssh.private_key_path = "custom_key_file"
  end
  </code></pre>
  
  <p>When done, each team member enter the following to get a virtual machine based on custom.box fast and easy:</p>
  
  <pre><code>vagrant box add custombox custom.box
  vagrant up
  </code></pre>
  
  <p>Works fine.</p>
  
  <p>Now i want to tune my baseline box a little bit before distributing. I want to include the "custom_key_file" and a "Vagrantfile.pkg" that reads as follows:</p>
  
  <pre><code># -*- mode: ruby -*-
  # vi: set ft=ruby :
  
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config.vm.box = "custombox"
      config.ssh.private_key_path = "custom_key_file"
  end
  </code></pre>
  
  <p>To create the tuned baseline box i enter:</p>
  
  <pre><code>vagrant package --output custom2v.box --vagrantfile Vagrantfile.pkg --include custom_key_file
  </code></pre>
  
  <p>When i extract the custom2v.box i can see there is this tree:</p>
  
  <pre><code>C:.
  │   box-disk1.vmdk
  │   box.ovf
  │   Vagrantfile
  │
  └───include
          custom_key_file
          _Vagrantfile
  </code></pre>
  
  <p>And "include/_Vagrantfile" has the content of my Vagrantfile.pkg. I can add that box as follows:</p>
  
  <pre><code>vagrant box add custombox2v custom2v.box
  </code></pre>
  
  <p>to a new project it is now very easy to enable it for vagrant. Just add a "Vagrantfile" read as follows:</p>
  
  <pre><code># -*- mode: ruby -*-
  # vi: set ft=ruby :
  
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
  VAGRANTFILE_API_VERSION = "2"
  
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
      config.vm.box = "custombox2v"
  end
  </code></pre>
  
  <p>But when i do a:</p>
  
  <pre><code>vagrant up
  </code></pre>
  
  <p>i get the following error message:</p>
  
  <pre><code>[...]
  Bringing machine 'default' up with 'virtualbox' provider...
  There are errors in the configuration of this machine. Please fix
  the following errors and try again:
  
  SSH:
  * `private_key_path` file must exist: custom_key_file
  </code></pre>
  
  <p>Can anyone help?</p>